On Oct 2, 11:20 am, Francis Moreau <francis.m... at gmail.com> wrote:
> Hello,
>> I'm looking at gcmodule.c and in move_unreachable() function, the code
> assumes that if an object has its gc.gc_refs stuff to 0 then it *may*
> be unreachable.
>> How can an object tagged as unreachable could suddenly become
> reachable later ?
>> Thanks
It looks like you're not reading through all of the comments:
GC_TENTATIVELY_UNREACHABLE
move_unreachable() then moves objects not reachable (whether
directly or
indirectly) from outside the generation into an "unreachable" set.
Objects that are found to be reachable have gc_refs set to
GC_REACHABLE
again. Objects that are found to be unreachable have gc_refs set
to
GC_TENTATIVELY_UNREACHABLE. It's "tentatively" because the pass
doing
this can't be sure until it ends, and GC_TENTATIVELY_UNREACHABLE
may
transition back to GC_REACHABLE.
Only objects with GC_TENTATIVELY_UNREACHABLE still set are
candidates
for collection. If it's decided not to collect such an object
(e.g.,
it has a __del__ method), its gc_refs is restored to GC_REACHABLE
again.