Red Hat Bugzilla – Bug 140715
sys.stdin segfaults on invalid stdin
Last modified: 2007-11-30 17:10:55 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Description of problem:
If stdin is invalid (e.g., redirected from a directory by mistake),
python interpreter segfaults on any attempt to access it.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. python -c 'import sys; sys.stdin' <.
Actual Results: Segmentation fault (core dumped)
Expected Results: In this case no output.
In a case where one actually tries to read sys.stdin, I would expect
Traceback (most recent call last):
File "<string>", line 1, in ?
IOError: [Errno 21] Is a directory
Reported upstream as bug
Upstream bug marked as a duplicate of:
and reportedly fixed in 2.4.3 and 2.5
Fedora Core 3 is now maintained by the Fedora Legacy project for security
updates only. If this problem is a security issue, please reopen and
reassign to the Fedora Legacy product. If it is not a security issue and
hasn't been resolved in the current FC5 updates or in the FC6 test
release, reopen and change the version to match.
Cannot comment on security for FL. It segfaults but I did not analyse the
implications of the faulty assertions it makes.
Updated FC5 contains python-2.4.3-8.FC5 where the bug is allegedly fixed
(comment #2). The alleged fix consists of aborting and dumping core
intentionally instead of involuntary. This is still a regression against older
Python versions (2.1?) where one got normal recoverable IOError exception. Of
course, when stderr is bogus too things can get pretty hairy in the default
exception handler and abort may be the only option.
The funamental problem is that programs are left without any chance to _check_
for an invalid standard stream and handle the situation themselves. It remains
In python 2.5 it reportedly exits without dumping core, but 2.5 seems irrelevant
even for FC6 so I haven't tried it.
Given "fundamental problem ... remains unfixed", this does indeed seem like an
Fixed in 2.5 and should also be fixed in the current fc6 update