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.

Author snoeberger
Recipients snoeberger
Date 2014-05-23.19:00:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400871636.0.0.265957974694.issue21563@psf.upfronthosting.co.za>
In-reply-to
Content
While embedding the Python 2.7 interpreter in an application, I have encountered a crash when the built-in function 'execfile' is invoked with one argument.

A file is attached, execfile_invoke.c, that reproduces the crash. The reproduction steps on my machine are the following:

% gcc -o execfile_invoke execfile_invoke.c -I/usr/include/python2.7 -L/usr/lib -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic
% ./execfile_invoke
Call execfile with one argument...
Segmentation fault
% 

I am using the following version of Python.

Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
[GCC 4.7.2] on linux2

The crash appears to occur because a call to PyEval_GetGlobals returns a NULL PyObject*,

globals = PyEval_GetGlobals();

and PyDict_GetItemString is called before a NULL check is performed.

In the Python 3 function builtin_exec, globals and locals are checked for NULL. If either is NULL, an exception with message "globals and locals cannot be NULL" is set.

if (!globals || !locals) {
     PyErr_SetString(PyExc_SystemError,
            "globals and locals cannot be NULL");
   return NULL;
}
History
Date User Action Args
2014-05-23 19:00:36snoebergersetrecipients: + snoeberger
2014-05-23 19:00:36snoebergersetmessageid: <1400871636.0.0.265957974694.issue21563@psf.upfronthosting.co.za>
2014-05-23 19:00:35snoebergerlinkissue21563 messages
2014-05-23 19:00:35snoebergercreate