File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1+ Fix two bugs related to the interaction of weakrefs and the garbage
2+ collector. The weakrefs in the ``tp_subclasses `` dictionary are needed in
3+ order to correctly invalidate type caches (for example, by calling
4+ ``PyType_Modified() ``). Clearing weakrefs before calling finalizers causes
5+ the caches to not be correctly invalidated. That can cause crashes since the
6+ caches can refer to invalid objects. This is fixed by deferring the
7+ clearing of weakrefs to classes and without callbacks until after finalizers
8+ are executed.
9+
10+ The second bug is caused by weakrefs created while running finalizers. Those
11+ weakrefs can be outside the set of unreachable garbage and therefore survive
12+ the ``delete_garbage() `` phase (where ``tp_clear() `` is called on objects).
13+ Those weakrefs can expose to Python-level code objects that have had
14+ ``tp_clear() `` called on them. See GH-91636 as an example of this kind of
15+ bug. This is fixes be clearing all weakrefs to unreachable objects after
16+ finalizers have been executed.
You can’t perform that action at this time.
0 commit comments