[ python-Bugs-1084766 ] sys.stdin segfaults on invalid stdin
SourceForge.net
noreply at sourceforge.net
Sun Dec 19 04:25:55 CET 2004
Bugs item #1084766, was opened at 2004-12-13 17:41
Message generated for change (Comment added) made by jepler
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1084766&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Mihai Ibanescu (misa)
Assigned to: Nobody/Anonymous (nobody)
Summary: sys.stdin segfaults on invalid stdin
Initial Comment:
Bug reported as:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=140715
If stdin is invalid (e.g., redirected from a directory
by mistake),
python interpreter segfaults on any attempt to access it.
In a case where one actually tries to read sys.stdin, I
would expect
something like
Traceback (most recent call last):
File "<string>", line 1, in ?
IOError: [Errno 21] Is a directory
----------------------------------------------------------------------
Comment By: Jeff Epler (jepler)
Date: 2004-12-18 21:25
Message:
Logged In: YES
user_id=2772
Duplicated here on a stale CVS version of 2.4. Here's some
information from gdb:
Starting program: /usr/src/cvs/python/dist/src/python -S -c
'' < /
[Thread debugging using libthread_db enabled]
[New Thread -151074304 (LWP 6154)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -151074304 (LWP 6154)]
0x08074f90 in PyDict_SetItem (op=0xf6fae79c, key=0xf6fb6f20,
value=0x0)
at Objects/dictobject.c:549
549 Py_INCREF(value);
(gdb) where
#0 0x08074f90 in PyDict_SetItem (op=0xf6fae79c,
key=0xf6fb6f20, value=0x0)
at Objects/dictobject.c:549
#1 0x08075e13 in PyDict_SetItemString (v=0xf6fae79c,
key=0x8109d60 "stdin",
item=0x0) at Objects/dictobject.c:1988
#2 0x080d6988 in _PySys_Init () at Python/sysmodule.c:961
#3 0x080d3e17 in Py_InitializeEx (install_sigs=1) at
Python/pythonrun.c:190
#4 0x080d5815 in Py_Initialize () at Python/pythonrun.c:283
#5 0x08055159 in Py_Main (argc=4, argv=0xfefac1b4) at
Modules/main.c:418
#6 0x08054e0f in main (argc=4, argv=0xfefac1b4) at
Modules/python.c:23
The problem seems to be that PyFile_FromFile() returns NULL
without tripping the PyErr_Occurred() test on my line 946 of
sysmodule.c, because the call to fill_file_fields() returns
NULL too.
It looks like fill_file_fields is supposed to return NULL
with an error set, but when dircheck() is called that early,
PyExc_IOError is NULL, so no error is set.
Maybe _PyExc_Init() must be moved earlier in startup.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1084766&group_id=5470
More information about the Python-bugs-list
mailing list