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

segfault calling sys.excepthook with non-Exception argument #47903

Closed
devdanzin mannequin opened this issue Aug 23, 2008 · 7 comments
Closed

segfault calling sys.excepthook with non-Exception argument #47903

devdanzin mannequin opened this issue Aug 23, 2008 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@devdanzin
Copy link
Mannequin

devdanzin mannequin commented Aug 23, 2008

BPO 3653
Nosy @birkenfeld, @pitrou, @vstinner, @devdanzin, @benjaminp
Files
  • print_exception.patch: Victor Stinner's patch for checking that value is an Exception (pythonrun.c)
  • use_unraiseable.patch
  • use_unraiseable_better.patch
  • 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 2008-08-23.20:08:22.897>
    created_at = <Date 2008-08-23.16:55:53.808>
    labels = ['interpreter-core', 'type-crash', 'release-blocker']
    title = 'segfault calling sys.excepthook with non-Exception argument'
    updated_at = <Date 2008-09-01.14:34:48.687>
    user = 'https://github.com/devdanzin'

    bugs.python.org fields:

    activity = <Date 2008-09-01.14:34:48.687>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-08-23.20:08:22.897>
    closer = 'benjamin.peterson'
    components = ['Interpreter Core']
    creation = <Date 2008-08-23.16:55:53.808>
    creator = 'ajaksu2'
    dependencies = []
    files = ['11229', '11231', '11234']
    hgrepos = []
    issue_num = 3653
    keywords = ['patch', 'needs review']
    message_count = 7.0
    messages = ['71807', '71811', '71812', '71815', '71816', '71833', '72254']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'pitrou', 'vstinner', 'ajaksu2', 'benjamin.peterson']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue3653'
    versions = ['Python 3.0']

    @devdanzin
    Copy link
    Mannequin Author

    devdanzin mannequin commented Aug 23, 2008

    Calling sys.excepthook(1,'1',1) crashes 3.0:

    Python 3.0b3+ (py3k:65987, Aug 23 2008, 10:04:31)
    [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys; sys.excepthook(1,'1',1)
    Segmentation fault

    gdb points at "PyException_GetTraceback at Objects/exceptions.c:265
    265 Py_XINCREF(base_self->traceback);"

    This was found by Fusil and Victor Stinner (haypo) sent me a patch (see
    attachment).

    Thanks bpeterson for triaging :)

    PS: I also think that bpo-3643 should be targeted to 3.0, as the
    underlying issue is the same, it would be an easy way to segfault
    python3.0 and has a clean patch available.

    @devdanzin devdanzin mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 23, 2008
    @birkenfeld
    Copy link
    Member

    Patch looks good.

    @benjaminp
    Copy link
    Contributor

    Ok. Applied in r65998.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 23, 2008

    The patch should probably used PyErr_Format() followed by
    PyErr_WriteUnraisable().

    @benjaminp
    Copy link
    Contributor

    Attaching new patch...

    @birkenfeld
    Copy link
    Member

    PyErr_Format sets the new exception and returns NULL though.

    @birkenfeld
    Copy link
    Member

    I think you need to clear the exception again before returning.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants