Bug 168419 - calling os.execl() with one argument crashes the interpreter
Summary: calling os.execl() with one argument crashes the interpreter
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: python
Version: rawhide
Hardware: All
OS: Linux
medium
low
Target Milestone: ---
Assignee: Mihai Ibanescu
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-09-15 20:46 UTC by Nalin Dahyabhai
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2005-10-03 17:34:58 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.