Skip to content

gh-117657: Fix data races when writing / reading ob_gc_bits - #118292

Merged
colesbury merged 4 commits into
python:mainfrom
mpage:gh-117657-tsan-gc-bits
May 8, 2024
Merged

colesbury merged 4 commits into
python:mainfrom
mpage:gh-117657-tsan-gc-bits

Conversation

@mpage

@mpage mpage commented Apr 25, 2024 •

Copy link
Copy Markdown
Contributor

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:

mpage added 2 commits April 25, 2024 11:36
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)
Comment thread Include/internal/pycore_object.h Resolved
@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 only security fixes label May 8, 2024
@colesbury
colesbury merged commit cb6f75a into python:main May 8, 2024
@miss-islington-app

Copy link
Copy Markdown

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 <mpage@meta.com>
@bedevere-app

bedevere-app Bot commented May 8, 2024

Copy link
Copy Markdown

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 only 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 <mpage@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants