Skip to content

raising an exception in a dict/code/function watcher callback will segfault on a DEALLOCATED event #102381

Closed

Description

@carljm

Because the object we pass into the callback is dead (zero refcount), and if the callback raises an error we try to PyErr_WriteUnraisable with that object as context, which increfs and decrefs it, which recursively again tries to deallocate it, and we end up in infinite recursion and overflowing the stack.

There are various other ways a callback could trigger this issue. We shouldn't pass around dead objects; instead *_dealloc should temporarily resurrect it before calling the callback.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Mar 2, 2023
  2. changed the title [-]raising an exception in a dict watcher callback will segfault on a DEALLOCATED event[/-] [+]raising an exception in a dict/code/function watcher callback will segfault on a DEALLOCATED event[/+] on Mar 3, 2023
  3. self-assigned this
    on Mar 3, 2023
  4. added a commit that references this issue on Mar 3, 2023
  5. added 2 commits that reference this issue on Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions