-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
GH-91636: Clear weakrefs created by finalizers. #136401
New issue
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
GH-91636: Clear weakrefs created by finalizers. #136401
Conversation
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
|
@colesbury In case you want to look at the free_threading_gc changes. |
|
Looks good to me. |
Add a boolean flag to indicate that callbacks should be enabled. This allows the same function to be used before and after finalizer execution.
| if (!allow_callbacks) { | ||
| return 0; | ||
| } | ||
|
|
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question: The old and allow_callbacks arguments are orthogonal even in older versions?
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
|
Yeah, you are right. I think it would be good to backport this one. |
|
This bug had been around for a while, let's wait for 3.14.1 for the backport rather than do it during RC. |
Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have
tp_clearcalled on them to Python-level code.Note that this is part of the GH-136189 change, split out to make it easier for back-porting. This change is conceptually quite simple and is a candidate to backport to all older Python versions (this bug existed for a long time, perhaps in version 2.3). There is some duplicated code between
handle_finalizersandclear_finalizersbut I think it's simpler just to leave that duplication. In the "main" branch I'll clean that up.