Crash because of ownership assert in `PyObject_ClearManagedDict`
Open
@sobolevn is already working on this.
Since Jun 26, 2026.
interpreter-core
type-crash
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Crash report
Refs https://github.com/python/cpython/issues/151763
Original description: https://gist.github.com/devdanzin/99b84915b197ae0ade7face262b8af66
Repro:
from unittest.mock import MagicMock
from _testcapi import set_nomemory
set_nomemory(200) # fail allocations from the 200th onward (lands in shutdown GC)
(MagicMock(), undefined_name) # build a MagicMock (managed __dict__), then NameError abandons
# it into a traceback cycle -> survives to shutdown GC
I have a fix ready.
Linked PRs
- gh-152255
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.