Skip to content

Commit 3cfb631

Browse files
committed
Queue frozen objects for decref.
1 parent 4345253 commit 3cfb631

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Python/gc_free_threading.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,11 @@ gc_visit_thread_stacks_mark_alive(PyInterpreterState *interp, gc_mark_args_t *ar
906906
static void
907907
queue_untracked_obj_decref(PyObject *op, struct collection_state *state)
908908
{
909-
if (!_PyObject_GC_IS_TRACKED(op)) {
909+
assert(Py_REFCNT(op) == 0);
910+
// We have to treat frozen objects as untracked in this function or else
911+
// they might be picked up in a future collection, which breaks the assumption
912+
// that all incoming objects have a non-zero reference count.
913+
if (!_PyObject_GC_IS_TRACKED(op) || gc_is_frozen(op)) {
910914
// GC objects with zero refcount are handled subsequently by the
911915
// GC as if they were cyclic trash, but we have to handle dead
912916
// non-GC objects here. Add one to the refcount so that we can

0 commit comments

Comments
 (0)