Message218988
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;
} |
|
Date |
User |
Action |
Args |
2014-05-23 19:00:36 | snoeberger | set | recipients:
+ snoeberger |
2014-05-23 19:00:36 | snoeberger | set | messageid: <1400871636.0.0.265957974694.issue21563@psf.upfronthosting.co.za> |
2014-05-23 19:00:35 | snoeberger | link | issue21563 messages |
2014-05-23 19:00:35 | snoeberger | create | |
|