Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segv during call to super_init in application embedding Python interpreter. #65617

Closed
ruibo mannequin opened this issue May 2, 2014 · 3 comments
Closed

Segv during call to super_init in application embedding Python interpreter. #65617

ruibo mannequin opened this issue May 2, 2014 · 3 comments
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ruibo
Copy link
Mannequin

ruibo mannequin commented May 2, 2014

BPO 21418
Nosy @vstinner, @benjaminp, @ruibo
Files
  • super_invoke.c
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-05-12.23:35:48.744>
    created_at = <Date 2014-05-02.19:22:40.702>
    labels = ['type-crash']
    title = 'Segv during call to super_init in application embedding Python interpreter.'
    updated_at = <Date 2014-05-12.23:35:48.743>
    user = 'https://github.com/ruibo'

    bugs.python.org fields:

    activity = <Date 2014-05-12.23:35:48.743>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-05-12.23:35:48.744>
    closer = 'vstinner'
    components = []
    creation = <Date 2014-05-02.19:22:40.702>
    creator = 'snoeberger'
    dependencies = []
    files = ['35131']
    hgrepos = []
    issue_num = 21418
    keywords = []
    message_count = 3.0
    messages = ['217777', '218377', '218378']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'benjamin.peterson', 'python-dev', 'snoeberger']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue21418'
    versions = ['Python 3.5']

    @ruibo
    Copy link
    Mannequin Author

    ruibo mannequin commented May 2, 2014

    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.

    @ruibo ruibo mannequin added the type-crash A hard crash of the interpreter, possibly with a core dump label May 2, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 12, 2014

    New changeset cee528d44b1e by Victor Stinner in branch '3.4':
    Issue bpo-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 bpo-21418: Fix a crash in the builtin function super() when
    http://hg.python.org/cpython/rev/53cf343c4fff

    @vstinner
    Copy link
    Member

    "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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant