Message354678
> I'm often amazed it works at all, let alone perfectly. ;-P
Indeed! Every time I take a break from gc and come back, I burn another hour wondering why it doesn't recycle _everything_ ;-)
> But what happens if the GC doesn't see that WZ is trash?
> Then it will not be cleared. Hang it off Y so the GC
> can't find it.
In that case it won't think C is trash either (a weakref holds a strong reference to its callback), so C won't be tp_clear'ed - if WZ isn't in the unreachable set, C can't be either.
> We can set things up so that Z is freed before WZ (e.g.
> WZ in a second and newer cycle). Then, the callback
> might still run.
Since C hasn't been damaged, and nothing reachable from C would have been considered trash either, I don't see a problem.
> On further thought, this seems safe (but maybe broken) because
> of the handle_weakrefs() logic. The GC will think WZ is going
> to outlive Z so it will call it before doing any tp_clear calls.
Don't think that applies. As above, WZ isn't in the unreachable set, so gc knows nothing about it.
Z will eventually be reclaimed via refcounting side effect, C _will_ run, and then WZ, and then C, will be reclaimed by refcounting.
Or am I missing something? |
|
Date |
User |
Action |
Args |
2019-10-15 00:19:06 | tim.peters | set | recipients:
+ tim.peters, nascheme, pitrou, vstinner, larry, christian.heimes, benjamin.peterson, ned.deily, petr.viktorin, methane, lukasz.langa, Mark.Shannon, jdemeyer, pablogsal, miss-islington |
2019-10-15 00:19:05 | tim.peters | set | messageid: <1571098745.91.0.653023783074.issue38006@roundup.psfhosted.org> |
2019-10-15 00:19:05 | tim.peters | link | issue38006 messages |
2019-10-15 00:19:05 | tim.peters | create | |
|