[ python-Bugs-887946 ] segfault if redirecting directory
SourceForge.net
noreply at sourceforge.net
Mon Oct 3 03:05:12 CEST 2005
Bugs item #887946, was opened at 2004-01-30 16:42
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=887946&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 6
Submitted By: Inyeol Lee (inyeol)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: segfault if redirecting directory
Initial Comment:
If redirecting directory, python crashes.
$ uname -a
SunOS xxxxx 5.8 Generic_108528-18 sun4u sparc
SUNW,Sun-Blade-1000
$ python
Python 2.3.2 (#1, Oct 9 2003, 18:59:04)
[GCC 2.95.3 20010315 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for
more information.
>>> ^D
$ mkdir foo
$ ls -F
foo/
$ python < foo
Segmentation Fault
-Inyeol Lee
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-10-02 18:05
Message:
Logged In: YES
user_id=33168
I fixed this problem and also added a warning when passing a
directory on the command line. Before the fix, python would
just silently exit which just bit me recently. (Same as
mbp's comment.)
Checked in as:
* Misc/NEWS: 1.1384, 1.1193.2.118
* Modules/main.c: 1.85, 1.84.2.1
* Python/sysmodule.c: 2.130, 2.126.2.4
* Lib/test/test_cmd_line.py: 1.1, 1.1.2.2
----------------------------------------------------------------------
Comment By: Martin Pool (mbp)
Date: 2005-06-05 22:32
Message:
Logged In: YES
user_id=521
Here is another failure, which might have the same root cause:
$ python /tmp
$ echo $?
0
I'd expect this to give an error.
----------------------------------------------------------------------
Comment By: Martin Pool (mbp)
Date: 2005-06-05 22:20
Message:
Logged In: YES
user_id=521
I doubt if libc checks whether the input is a directory;
there are possible (though extremely obscure) cases where
you might want to do that.
I think you probably need something along the lines of
fstat(0, &buf), then check the st_mode. Remember that fifos
and chardevs ought to be allowed.
----------------------------------------------------------------------
Comment By: Nick Coghlan (ncoghlan)
Date: 2004-11-22 04:32
Message:
Logged In: YES
user_id=1038590
Python's C main function assumes stdin, stdout and stderr
are all valid FILE pointers.
A little experimentation on a Linux box should establish
what glibc is providing when the input pipe isn't a proper
file (probably stdin == NULL given the symptoms, but that's
just a guess)
A sanity check on stdin should then be possible near the
start of the main function.
----------------------------------------------------------------------
Comment By: Nick Coghlan (ncoghlan)
Date: 2004-11-22 04:24
Message:
Logged In: YES
user_id=1038590
Win XP SP 1 -
C:\Python24>python < Lib
"Access is Denied"
----------------------------------------------------------------------
Comment By: Inyeol Lee (inyeol)
Date: 2004-11-04 11:10
Message:
Logged In: YES
user_id=595280
I did some more test among different versions;
2.4b1/Solaris - segfault
2.3.3/Linux - segfault
2.3.2/Solaris - segfault
2.1.1/Linux - OK
1.5.2/Linux - OK
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=887946&group_id=5470
More information about the Python-bugs-list
mailing list