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.

classification
Title: Segv during call to super_init in application embedding Python interpreter.
Type: crash Stage:
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, python-dev, snoeberger, vstinner
Priority: normal Keywords:

Created on 2014-05-02 19:22 by snoeberger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
super_invoke.c snoeberger, 2014-05-02 19:22
Messages (3)
msg217777 - (view) Author: Robert Snoeberger (snoeberger) Date: 2014-05-02 19:22
While embedding the Python interpreter in an application, I have encountered a crash when the built-in function 'super' is invoked with no arguments. The crash occurs during a call to PyObject_Call.

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

% gcc -o super_invoke super_invoke.c -I/path_to_py/include/python3.5m -L/path_to_py/lib -lpthread -ldl -lutil -lm -lpython3.5m -Xlinker -export-dynamic 
% ./super_invoke 
Call super with no arguments...
Segmentation fault
% 

The crash appears to occur in the function super_init contained in the file Objects/typeobject.c. The code path enters the if statement that checks for no input arguments. The following two lines cause the crash.

PyFrameObject *f = PyThreadState_GET()->frame;
PyCodeObject *co = f->f_code;

The PyFrameObject pointer 'f' is NULL.
msg218377 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-12 23:33
New changeset cee528d44b1e by Victor Stinner in branch '3.4':
Issue #21418: Fix a crash in the builtin function super() when called without
http://hg.python.org/cpython/rev/cee528d44b1e

New changeset 53cf343c4fff by Victor Stinner in branch 'default':
(Merge 3.4) Issue #21418: Fix a crash in the builtin function super() when
http://hg.python.org/cpython/rev/53cf343c4fff
msg218378 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-05-12 23:35
"While embedding the Python interpreter in an application, I have encountered a crash when the built-in function 'super' is invoked with no arguments."

This is not supported. When super() is invoked with no arguments, the class is retrieved (indirectly) from the current frame. In your example, there is no current frame. You can workaround this limitation by passing explicitly the class to super.

The crash should be fixed: a RuntimeError is now raised.
History
Date User Action Args
2022-04-11 14:58:03adminsetgithub: 65617
2014-05-12 23:35:48vstinnersetstatus: open -> closed
resolution: fixed
2014-05-12 23:35:40vstinnersetmessages: + msg218378
2014-05-12 23:33:17python-devsetnosy: + python-dev
messages: + msg218377
2014-05-04 22:07:47pitrousetnosy: + benjamin.peterson
2014-05-02 19:50:56vstinnersetnosy: + vstinner
2014-05-02 19:22:40snoebergercreate