Bug 168419 - calling os.execl() with one argument crashes the interpreter
calling os.execl() with one argument crashes the interpreter
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: python (Show other bugs)
rawhide
All Linux
medium Severity low
: ---
: ---
Assigned To: Mihai Ibanescu
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-09-15 16:46 EDT by Nalin Dahyabhai
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-10-03 13:34:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Nalin Dahyabhai 2005-09-15 16:46:57 EDT
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 11:32:51 EDT
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 13:22:59 EDT
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 13:34:58 EDT
+1 ==> NOTABUG

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