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-117657: Fix data races when writing / reading ob_gc_bits #118292

Merged
merged 4 commits into from
May 8, 2024

Conversation

mpage
Copy link
Contributor

@mpage mpage commented Apr 25, 2024

Use relaxed atomics when reading / writing to the field. There are still a few places in the GC where we do not use atomics. Those should be safe as the world is stopped.

Sample races reported by TSAN:

Use relaxed atomics when reading / writing to the field. There are still a
few places in the GC where we do not use atomics. Those should be safe as
the world is stopped.

Sample races reported by TSAN:

* [Race between `_PyObject_GC_IS_SHARED()` and `_PyObject_GC_SET_SHARED()`](https://gist.github.com/mpage/ebfd022773f39c33bec68c0993a2249e)
* [Race between `_PyObject_GC_TRACK()` and `_PyObject_GC_IS_SHARED()`](https://gist.github.com/mpage/b53b5c22a2f923bf1571b887bb31ef88)
@mpage mpage requested a review from DinoV April 25, 2024 20:42
@mpage mpage marked this pull request as ready for review May 7, 2024 17:26
@mpage mpage requested a review from colesbury May 7, 2024 17:26
@colesbury colesbury added the needs backport to 3.13 bugs and security fixes label May 8, 2024
@colesbury colesbury merged commit cb6f75a into python:main May 8, 2024
38 checks passed
@miss-islington-app
Copy link

Thanks @mpage for the PR, and @colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 8, 2024
…ythonGH-118292)

Use relaxed atomics when reading / writing to the field. There are still a
few places in the GC where we do not use atomics. Those should be safe as
the world is stopped.
(cherry picked from commit cb6f75a)

Co-authored-by: mpage <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented May 8, 2024

GH-118796 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 8, 2024
colesbury pushed a commit that referenced this pull request May 8, 2024
…H-118292) (#118796)

Use relaxed atomics when reading / writing to the field. There are still a
few places in the GC where we do not use atomics. Those should be safe as
the world is stopped.
(cherry picked from commit cb6f75a)

Co-authored-by: mpage <[email protected]>
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