Author tim.peters
Recipients Mark.Shannon, christian.heimes, inada.naoki, jdemeyer, lukasz.langa, miss-islington, nascheme, pablogsal, petr.viktorin, pitrou, tim.peters, vstinner
Date 2019-09-30.16:22:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569860542.68.0.733087110047.issue38006@roundup.psfhosted.org>
In-reply-to
Content
> Would the attached rough patch (gc_disable_wr_callback.txt)
> be a possible fix?  When we find W inside handle_weakrefs(),
> we mark it as trash and will not execute the callback.

It's semantically correct since we never wanted to execute a callback from a trash weakref to begin with.  The nature of the error violated that intent:  the callback from a trash weakref occurs outside gcmodule, where it has no idea that the weakref is trash.  After your patch, it would know.

How effective is it?  Well, failure modes "like this" ;-)

If a callback function is trash, delete_garbage will eventually clear it.  But if the function is trash the weakref containing it must also be trash (if it weren't trash, neither would be the reachable-from-it callback function).  Then since the containing weakref is trash, your patch will find it and prevent the callback.

So this "should" fix the original problem, even if tp_clear were restored for function objects (which it probably should be).
History
Date User Action Args
2019-09-30 16:22:22tim.peterssetrecipients: + tim.peters, nascheme, pitrou, vstinner, christian.heimes, petr.viktorin, inada.naoki, lukasz.langa, Mark.Shannon, jdemeyer, pablogsal, miss-islington
2019-09-30 16:22:22tim.peterssetmessageid: <1569860542.68.0.733087110047.issue38006@roundup.psfhosted.org>
2019-09-30 16:22:22tim.peterslinkissue38006 messages
2019-09-30 16:22:22tim.peterscreate