Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a bug due to the interaction of weakrefs and the cyclic garbage collector. We must clear any weakrefs in garbage in order to prevent their callbacks from executing and causing a crash.
|
@ambv: Please replace |
|
GH-16499 is a backport of this pull request to the 3.8 branch. |
|
Should we backport to all maintained branches? I think it applies even to 2.7. |
Ya, these holes have been there since the day weakrefs were added to the language. |
Fix a bug due to the interaction of weakrefs and the cyclic garbage collector. We must clear any weakrefs in garbage in order to prevent their callbacks from executing and causing a crash. (cherry picked from commit bcda460) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
|
Uh, I'm a bit anxious about this. This is added to workaround a crash that's caused by a container not implementing the GC protocol correctly. But in turn it may silence the invocation of many legitimate weakref callbacks. Weakref callbacks are often used to release external resources (for example system resources). This is actually the original motivation for weakref.finalize, which was originally a I may be misreading the patch, but if a Edit: ok, I read through the "Headache time" part and it's clearer now :-) My bad. |
|
To be sure we're on the same page, it was always the case that we suppressed callbacks from trash weakrefs. If the user wants the callback to be invoked for sure, it's the user's responsibility to ensure the weakref outlives the referent. What did change is that a missing I bet we could run more callbacks now, since you added a pass to abort the gc run if trash got resurrected. But I never heard anyone ask for that, and don't want it myself |
Fix a bug due to the interaction of weakrefs and the cyclic garbage collector. We must clear any weakrefs in garbage in order to prevent their callbacks from executing and causing a crash.
nascheme commentedSep 30, 2019
•
edited by bedevere-bot
Fix a bug due to the interaction of weakrefs and the cyclic garbage
collector. We must clear any weakrefs in garbage in order to prevent
their callbacks from executing and causing a crash.
https://bugs.python.org/issue38006
The text was updated successfully, but these errors were encountered: