Skip to content

Commit 65f11d9

Browse files
committed
Skip untracked objects in weak reachable GC traversal
1 parent ac12267 commit 65f11d9

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • graalpython/com.oracle.graal.python.cext/src

graalpython/com.oracle.graal.python.cext/src/gcmodule.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,13 @@ visit_weak_reachable(PyObject *op, PyGC_Head *reachable)
554554
return 0;
555555
}
556556

557+
/* Untracked objects cannot be weak candidates, even if they are reached
558+
* from a container traversed in this phase.
559+
*/
560+
if (!_PyObject_GC_IS_TRACKED(op)) {
561+
return 0;
562+
}
563+
557564
PyGC_Head *gc = AS_GC(op);
558565

559566
/* 'visit_reachable' tests at this point for 'gc_is_collecting(gc)'.
@@ -563,10 +570,6 @@ visit_weak_reachable(PyObject *op, PyGC_Head *reachable)
563570
* 'NEXT_MASK_UNREACHABLE' is set.
564571
*/
565572

566-
// It would be a logic error elsewhere if the collecting flag were set on
567-
// an untracked object.
568-
assert(UNTAG(gc)->_gc_next != 0);
569-
570573
/* Note: one could expect that we need to test
571574
* 'gc_get_refs(gc) == MANAGED_REFCNT' but that's no longer true because in
572575
* the previous phase (i.e. 'move_unreachable') when we move the object into

0 commit comments

Comments
 (0)