[3.13] gh-121794: Don't set ob_tid to zero in fast-path dealloc (GH-121799)#121821
Merged
colesbury merged 1 commit intopython:3.13from Jul 15, 2024
Merged
[3.13] gh-121794: Don't set ob_tid to zero in fast-path dealloc (GH-121799)#121821colesbury merged 1 commit intopython:3.13from
ob_tid to zero in fast-path dealloc (GH-121799)#121821colesbury merged 1 commit intopython:3.13from
Conversation
…honGH-121799) We should maintain the invariant that a zero `ob_tid` implies the refcount fields are merged. * Move the assignment in `_Py_MergeZeroLocalRefcount` to immediately before the refcount merge. * Update `_PyTrash_thread_destroy_chain` to set `ob_ref_shared` to `_Py_REF_MERGED` when setting `ob_tid` to zero. Also check this invariant with assertions in the GC in debug builds. That uncovered a bug when running out of memory during GC. (cherry picked from commit d23be39) Co-authored-by: Sam Gross <colesbury@gmail.com>
This was referenced Jul 15, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We should maintain the invariant that a zero
ob_tidimplies therefcount fields are merged.
_Py_MergeZeroLocalRefcountto immediatelybefore the refcount merge.
_PyTrash_thread_destroy_chainto setob_ref_sharedto_Py_REF_MERGEDwhen settingob_tidto zero.Also check this invariant with assertions in the GC in debug builds.
That uncovered a bug when running out of memory during GC.
(cherry picked from commit d23be39)
Co-authored-by: Sam Gross colesbury@gmail.com
_Py_MergeZeroLocalRefcountshould not setob_tidto zero in fast-path dealloc #121794