This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: segfault in os module
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, jacobo_es, loewis
Priority: normal Keywords:

Created on 2005-06-24 13:05 by jacobo_es, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python_crash.2 jacobo_es, 2005-06-24 13:05 prove & gdb debugging
Messages (5)
msg25623 - (view) Author: jacobo_es (jacobo_es) Date: 2005-06-24 13:05
python crashes when a bad parameters are passed to execl function        
of the os module:        
>>> import os        
>>> os.execl("/bin/bash")        
Segmentation Fault (core dumped)        
        
No matter the platform (on ppc raises a bus error) and the version of      
C compiler,  always crashes, python versions used are 2.4.1 and    
2.4c1.      
      
Proved on MacOSX (ppc), and Knoppix, Red Hat  Enterprise   
and debian woody 3.0 (x86).   
  
However, on 2.2.3 version not crashes.  
msg25624 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-24 14:53
Logged In: YES 
user_id=1188172

This behaviour was introduced with the fixing of bug
#952953, where someone complained that he couldn't call
execl with only one argument.

I tried this directly on the C layer on Linux, and it
segfaults too.
Are there OSes where this is legal?
msg25625 - (view) Author: jacobo_es (jacobo_es) Date: 2005-06-25 23:15
Logged In: YES 
user_id=1302185

I tried this directly on the C layer, too, and not raises a
signal 11, segmentation fault, just the function execl()
isn't executed and the program flow goes, not raises a
sigsegv, and that's not happen in 
the same way in python, that abort the python interpreter
and dump a core file.

-( tmp )- ./p
execl not executed.
-( tmp )- cat p.c
#include <stdio.h>

int main() {
        execl("/bin/bash");
        fprintf(stderr, "execl not executed.\n");
        exit(-1);
}
msg25626 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-26 06:19
Logged In: YES 
user_id=1188172

First, Python does not call the C execl functions, but
translates them to execv calls.

For execv called like Python does:

~/tmp> ./execv
zsh: 15395 segmentation fault  ./execv
~/tmp> cat execv.c
#include <unistd.h>
#include <errno.h>

int main() {
    const char* args[1];
    args[0] = NULL;

    execv("/bin/bash", args);
    return errno;
}


For execl on the C layer, my Linux doesn't want that:

~/tmp> gcc -o execl execl.c
execl.c: In function `main':
execl.c:4: error: too few arguments to function 'execl'
~/tmp> cat execv.c
#include <unistd.h>

int main() {
    execl("/bin/bash");
    return 0;
}
msg25627 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-08-06 13:19
Logged In: YES 
user_id=21627

There is nothing wrong with Python here. It is not Python
that crashes, but /bin/bash. Just try a different binary
(/usr/bin/id worked for me); use strace to see that it is
indeed the new process that crashes.

Closing as invalid.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42116
2005-06-24 13:05:07jacobo_escreate