Skip to content

[3.13] gh-121794: Don't set ob_tid to zero in fast-path dealloc (GH-121799) #121821

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

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 15, 2024

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 [email protected]

…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 <[email protected]>
@colesbury colesbury enabled auto-merge (squash) July 15, 2024 21:52
@colesbury colesbury merged commit 0794220 into python:3.13 Jul 15, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants