Bug 168419

Summary: calling os.execl() with one argument crashes the interpreter
Product: [Fedora] Fedora Reporter: Nalin Dahyabhai <nalin>
Component: pythonAssignee: Mihai Ibanescu <mihai.ibanescu>
Status: CLOSED NOTABUG QA Contact: Brock Organ <borgan>
Severity: low Docs Contact:
Priority: medium    
Version: rawhideCC: katzj
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-10-03 17:34:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nalin Dahyabhai 2005-09-15 20:46:57 UTC
Description of problem:
In jest, I tried this:
  import os; os.execl("/bin/bash")
and the interpreter crashed instead if displaying an error.

Version-Release number of selected component (if applicable):
2.4.1-2

How reproducible:
Always

Steps to Reproduce:
1. python -c 'import os; os.execl("/bin/bash")'
  
Actual results:
segmentation fault

Expected results:
Either a shell prompt or an error message warning that the second argument is
not optional.

Comment 1 Mihai Ibanescu 2005-09-30 15:32:51 UTC
This doesn't necessarily seem to be a problem in python's implementation of
execl.

Try to replace /bin/bash with /bin/ls. It works for me (/bin/bash segfaults
for me too).

strace -f shows the error being somewhere else, but can't really tell.

I tried this:

#include <stdio.h>
#include <unistd.h>

int main()
{
    //char *const args[] = {"/bin/bash", NULL};
    char *const args[] = {NULL};
    execv(args[0], args);
    return 0;
}


This one works fine, even thogh, according to execv(3) the behaviour would be
undefined (should vs. must):

       The execv and execvp functions provide an array of pointers to
null-terminated  strings  that
       represent  the argument list available to the new program.  The first
argument, by convention,
       should point to the file name associated with the file being executed.
The array of  pointers
       must be terminated by a NULL pointer.


Needs more investigation.

Comment 2 Nalin Dahyabhai 2005-10-03 17:22:59 UTC
I agree.  If I run this under strace, it's clear that the exec() succeeds, and
that the crash is actually in the shell.  I'm okay with closing this as invalid.

Comment 3 Jeremy Katz 2005-10-03 17:34:58 UTC
+1 ==> NOTABUG