There was an error while loading. Please reload this page.
1 parent 700c2fd commit cde931dCopy full SHA for cde931d
1 file changed
Python/gc_free_threading.c
@@ -324,8 +324,11 @@ gc_visit_thread_stacks(PyInterpreterState *interp)
324
_PyInterpreterFrame *curr_frame = p->current_frame;
325
while (curr_frame != NULL) {
326
PyCodeObject *co = (PyCodeObject *)curr_frame->f_executable;
327
- for (int i = 0; i < co->co_nlocalsplus + co->co_stacksize; i++) {
328
- gc_visit_stackref(curr_frame->localsplus[i]);
+ if (co != NULL && PyCode_Check(co)) {
+ for (int i = 0;
329
+ i < co->co_nlocalsplus + co->co_stacksize; i++) {
330
+ gc_visit_stackref(curr_frame->localsplus[i]);
331
+ }
332
}
333
curr_frame = curr_frame->previous;
334
@@ -585,14 +588,14 @@ deduce_unreachable_heap(PyInterpreterState *interp,
585
588
// incoming references.
586
589
gc_visit_heaps(interp, &update_refs, &state->base);
587
590
- gc_visit_thread_stacks(interp);
-
591
#ifdef GC_DEBUG
592
// Check that all objects are marked as unreachable and that the computed
593
// reference count difference (stored in `ob_tid`) is non-negative.
594
gc_visit_heaps(interp, &validate_gc_objects, &state->base);
595
#endif
596
597
+ gc_visit_thread_stacks(interp);
598
+
599
// Transitively mark reachable objects by clearing the
600
// _PyGC_BITS_UNREACHABLE flag.
601
if (gc_visit_heaps(interp, &mark_heap_visitor, &state->base) < 0) {
0 commit comments