Skip to content

gh-111926: Update _PyWeakref_IS_DEAD to be thread-safe - #112267

Merged
corona10 merged 3 commits into
python:mainfrom
corona10:gh-111926-dead
Nov 19, 2023
Merged

corona10 merged 3 commits into
python:mainfrom
corona10:gh-111926-dead

Conversation

@corona10

@corona10 corona10 commented Nov 19, 2023 •

Copy link
Copy Markdown
Member
@corona10
corona10 requested a review from colesbury November 19, 2023 12:59
@corona10 corona10 changed the title gh-111926 Update _PyWeakref_IS_DEAD to be thread-safe Nov 19, 2023

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good for now, but we'll need to come back to this again after other parts of weakrefobject.c are updated.

Py_REFCNT(obj) == 0 won't be sufficient here without the GIL. Outside of destructors, Py_REFCNT() is basically an estimate subject to race conditions. We'll want a check that ob_ref_shared == _Py_REF_MERGED, but we can't rely on that test either until we make some other changes to weakrefobject.c

@corona10
corona10 merged commit 7c9f267 into python:main Nov 19, 2023
@corona10
corona10 deleted the gh-111926-dead branch November 19, 2023 22:36
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants