This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients brandtbucher, pablogsal, rhettinger, serhiy.storchaka, tim.peters, vstinner
Date 2020-12-03.22:13:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607033597.17.0.388795887836.issue42536@roundup.psfhosted.org>
In-reply-to
Content
> I added some comments in the PR regarding the possibility of forcing the tracking on the visiting function

Thinking about this more, I'm a bit hesitant to put the re-tracking code in the traverse function (mostly stemming from my lack of knowledge about our GC algorithm). I have no idea how problematic tracking and untracking objects *during* collections can be. Consider the following reference chain:

-> z -> r -> o -> r

Here, z is a zip iterator, r is its result tuple, and o is some object. Let's say r was untracked in the previous collection (I believe untrack_tuples happens *after* all of the traverse functions are called).

I'm worried that the GC may not be able to detect the cycle if it visits o, then z (which *then* starts tracking r), then r.

Or, if this group is determined to be unreachable, untrack_tuples untracks r *before* the cycle is cleaned up. That seems like it could be a problem.

Or, if z's refcount drops to zero and it's cleaned up, its traverse function may *never* be called, which leaves the untracked r -> o -> r cycle.

I guess I'm just not sure how resilient the GC is to these sorts of things. Re-tracking the result tuple in __next__ sidesteps all of these potential issues, with no significant performance impact. So I think I might slightly prefer that.
History
Date User Action Args
2020-12-03 22:13:17brandtbuchersetrecipients: + brandtbucher, tim.peters, rhettinger, vstinner, serhiy.storchaka, pablogsal
2020-12-03 22:13:17brandtbuchersetmessageid: <1607033597.17.0.388795887836.issue42536@roundup.psfhosted.org>
2020-12-03 22:13:17brandtbucherlinkissue42536 messages
2020-12-03 22:13:16brandtbuchercreate