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: Quiet TSAN warning about a data race between start_the_world() and tstate_try_attach() #117828

Merged
merged 2 commits into from
Apr 15, 2024

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.
Python/pystate.c Outdated Show resolved Hide resolved
@colesbury colesbury merged commit 6e0b327 into python:main Apr 15, 2024
37 checks passed
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