Closed
Description
Feature or enhancement
The free threading GC traverses the active frames of threads in two places:
- When
GC_MARK_ALIVE_STACKS
during the marking phase (see Add marking phase to free-threaded cyclic GC #128807) - During
deduce_unreachable_heap
to ensure that deferred reference counted objects are kept alive.
Previously, the frame's stackpointer was frequently not set during GC. To avoid missing some deferred references, we looked at the frame up to the maximum size (co->co_stacksize
). That behavior isn't great:
- We can only look at deferred references, because non-deferred references may be dead objects reclaimed by normal reference counting operations.
- We need to zero-initialize the entire stack when pushing a frame
Now that the frame's stackpointer is nearly always set during GC, we should only look at the frame up to f->stackpointer
. There are still some cases where the stackpointer isn't set currently; we'll (temporarily) need some fallback for those cases. Once the stackpointer is always valid during GC (ideally before the 3.14 release), we can remove the fallback and assert that f->stackpointer
is not NULL
.
cc @nascheme