Skip to content
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

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

Merged
merged 3 commits into from
Nov 19, 2023

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Nov 19, 2023

@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 gh-111926: Update _PyWeakref_IS_DEAD to be thread-safe Nov 19, 2023
Copy link
Contributor

@colesbury colesbury left a comment

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants