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

Raising in an atexit function in dev mode crashes #90183

Closed
pablogsal opened this issue Dec 9, 2021 · 6 comments
Closed

Raising in an atexit function in dev mode crashes #90183

pablogsal opened this issue Dec 9, 2021 · 6 comments
Labels
3.10 only security fixes 3.11 only security fixes

Comments

@pablogsal
Copy link
Member

BPO 46025
Nosy @vstinner, @pablogsal, @miss-islington
PRs
  • bpo-46025: Fix a crash in the atexit module for auto-unregistering functions #30002
  • [3.10] bpo-46025: Fix a crash in the atexit module for auto-unregistering functions (GH-30002) #30005
  • 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 2021-12-09.15:15:34.300>
    created_at = <Date 2021-12-09.11:20:52.793>
    labels = ['3.10', '3.11']
    title = 'Raising in an atexit function in dev mode crashes'
    updated_at = <Date 2021-12-09.17:06:29.881>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2021-12-09.17:06:29.881>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-09.15:15:34.300>
    closer = 'pablogsal'
    components = []
    creation = <Date 2021-12-09.11:20:52.793>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46025
    keywords = ['patch', '3.10regression', '3.11regression']
    message_count = 6.0
    messages = ['408106', '408123', '408132', '408143', '408144', '408147']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'pablogsal', 'miss-islington']
    pr_nums = ['30002', '30005']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46025'
    versions = ['Python 3.10', 'Python 3.11']

    @pablogsal
    Copy link
    Member Author

    Issue found by Matt Wozniski:

    Running this with python3.10 -X dev segfaults:

    import atexit
    def func():
        atexit.unregister(func)
        1/0
    atexit.register(func)

    @pablogsal pablogsal added 3.10 only security fixes 3.11 only security fixes labels Dec 9, 2021
    @pablogsal
    Copy link
    Member Author

    New changeset f0d290d by Pablo Galindo Salgado in branch 'main':
    bpo-46025: Fix a crash in the atexit module for auto-unregistering functions (GH-30002)
    f0d290d

    @pablogsal
    Copy link
    Member Author

    New changeset 934a24c by Miss Islington (bot) in branch '3.10':
    bpo-46025: Fix a crash in the atexit module for auto-unregistering functions (GH-30002) (GH-30005)
    934a24c

    @vstinner
    Copy link
    Member

    vstinner commented Dec 9, 2021

    Interesting bug report! Thanks for the fix ;-)

    @vstinner
    Copy link
    Member

    vstinner commented Dec 9, 2021

    For me, the question is why would anyone call atexit.unregister() inside an atexit callback. Is it useful?

    atexit._run_exitfuncs() removes all registered callbacks.

    Py_Finalize() calls _PyAtExit_Call() which also removes all registered callbacks.

    @pablogsal
    Copy link
    Member Author

    For me, the question is why would anyone call atexit.unregister() inside an atexit callback. Is it useful?

    Is not useful, is just an edge case

    @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
    3.10 only security fixes 3.11 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants