-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-135909: Assert incoming refcnt != 0 for the free threaded GC. #136009
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
base: main
Are you sure you want to change the base?
Conversation
This is to catch out double deallocation bugs. Likely from a faulty .tp_dealloc allowing the GC to run before the object is untracked. This assert matches the one added to the GIL build, in 780c497. The call to validate_refcounts was moved up to start of the GC because queue_untracked_obj_decref() creates it own zero reference count garbage.
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
// the object. The likely cause for hitting this is a faulty .tp_dealloc. | ||
// Also see the comment in `update_refs()`. | ||
_PyObject_ASSERT_WITH_MSG(op, Py_REFCNT(op) > 0, | ||
"tracked objects must have a reference count > 0"); |
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.
If we're trying to mimick the default GC, let's use the same error message:
"tracked objects must have a reference count > 0"); | |
"refcount is too small"); |
🤖 New build scheduled with the buildbot fleet by @colesbury for commit 0882016 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136009%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
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.
Thanks, LGTM!
This is to catch out double deallocation bugs. Likely from a faulty .tp_dealloc allowing the GC to run before the object is untracked.
This assert matches the one added to the GIL build, in 780c497. The call to validate_refcounts was moved up to start of the GC because queue_untracked_obj_decref() creates it own zero reference count garbage.