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

gh-111926: Update _PyWeakref_IS_DEAD to be thread-safe#112267
corona10 merged 3 commits into
python:mainfrom
corona10:gh-111926-dead

Conversation

@corona10

@corona10corona10 commented Nov 19, 2023

Copy link
Copy Markdown
Member

@corona10corona10 changed the title gh-111926 Update _PyWeakref_IS_DEAD to be thread-safegh-111926: Update _PyWeakref_IS_DEAD to be thread-safeNov 19, 2023

@colesburycolesbury 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:mainNov 19, 2023
@corona10
corona10 deleted the gh-111926-dead branch November 19, 2023 22:36
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for freeto 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

@corona10@colesbury