Skip to content

gh-117657: Quiet TSAN warning about a data race between start_the_world() and tstate_try_attach()#117828

Merged
colesbury merged 2 commits intopython:mainfrom
mpage:gh-117657-start_the_world
Apr 15, 2024
Merged

gh-117657: Quiet TSAN warning about a data race between start_the_world() and tstate_try_attach()#117828
colesbury merged 2 commits intopython:mainfrom
mpage:gh-117657-start_the_world

Conversation

@mpage
Copy link
Contributor

@mpage mpage commented Apr 12, 2024

TSAN erroneously reports a data race (example) between the _Py_atomic_compare_exchange_int on tstate->state in tstate_try_attach():

cpython/Python/pystate.c

Lines 1993 to 1995 in 069de14

return _Py_atomic_compare_exchange_int(&tstate->state,
&expected,
_Py_THREAD_ATTACHED);

and the non-atomic load of tstate->state in start_the_world():

assert(t->state == _Py_THREAD_SUSPENDED);

The _Py_atomic_compare_exchange_int fails, but TSAN erroneously treats it as a store.

…`tstate_try_attach()`

TSAN erroneously reports a data race between the `_Py_atomic_compare_exchange_int`
on `tstate->state` in `tstate_try_attach()` and the non-atomic load of
`tstate->state` in `start_the_world`. The `_Py_atomic_compare_exchange_int` fails,
but TSAN erroneously treats it as a store.
@colesbury colesbury merged commit 6e0b327 into python:main Apr 15, 2024
mpage added a commit to mpage/cpython that referenced this pull request Apr 16, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…the_world()` and `tstate_try_attach()` (python#117828)

TSAN erroneously reports a data race between the `_Py_atomic_compare_exchange_int`
on `tstate->state` in `tstate_try_attach()` and the non-atomic load of
`tstate->state` in `start_the_world`. The `_Py_atomic_compare_exchange_int` fails,
but TSAN erroneously treats it as a store.
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