Skip to content

Commit 496c0b1

Browse files
committed
Add NEWS.
1 parent 123bc25 commit 496c0b1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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.

0 commit comments

Comments
 (0)