[ python-Bugs-887946 ] segfault if redirecting directory

SourceForge.net noreply at sourceforge.net
Mon Jun 6 07:32:43 CEST 2005


Bugs item #887946, was opened at 2004-01-31 11:42
Message generated for change (Comment added) made by mbp
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: Open
Resolution: None
Priority: 6
Submitted By: Inyeol Lee (inyeol)
Assigned to: Nobody/Anonymous (nobody)
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: Martin Pool (mbp)
Date: 2005-06-06 15: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-06 15: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 23: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 23: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-05 06: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