Skip to content

Raising in an atexit function in dev mode crashes #90183

Description

@pablogsal
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']

    Activity

    1. pablogsal commented on Dec 9, 2021

      @pablogsal
      MemberAuthor

      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)
    2. pablogsal commented on Dec 9, 2021

      @pablogsal
      MemberAuthor

      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

    3. pablogsal commented on Dec 9, 2021

      @pablogsal
      MemberAuthor

      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

    4. vstinner commented on Dec 9, 2021

      @vstinner
      Member

      Interesting bug report! Thanks for the fix ;-)

    5. vstinner commented on Dec 9, 2021

      @vstinner
      Member

      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.

    6. pablogsal commented on Dec 9, 2021

      @pablogsal
      MemberAuthor

      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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.11only security fixes

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions