Skip to content

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

Closed
@carljm

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

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