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 TSAN race in QSBR assertion #119887

Merged
merged 2 commits into from
Jun 1, 2024

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented May 31, 2024

Due to a limitation of TSAN, all reads from PyThreadState.state must be atomic to avoid reported races.

Due to a limitation in TSAN, all reads from PyThreadState.state must be
atomic to avoid reported races.
@colesbury colesbury merged commit 90ec19f into python:main Jun 1, 2024
36 checks passed
@miss-islington-app
Copy link

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

@colesbury colesbury deleted the gh-117657-qsbr branch June 1, 2024 14:04
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 1, 2024
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
(cherry picked from commit 90ec19f)

Co-authored-by: Sam Gross <colesbury@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 1, 2024

GH-119904 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 Jun 1, 2024
colesbury added a commit that referenced this pull request Jun 1, 2024
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
(cherry picked from commit 90ec19f)

Co-authored-by: Sam Gross <colesbury@gmail.com>
@wiggin15
Copy link
Contributor

wiggin15 commented Jun 1, 2024

Don't we want to use the FT_ATOMIC_LOAD_* macro from pycore_pyatomic_ft_wrappers.h to avoid affecting the GIL code?

@colesbury
Copy link
Contributor Author

No:

  • it's in qsbr.c, which is only used in the free-threaded build.
  • it's in an assertion (so debug only)
  • using the FT_* macros in places where there's no performance reason to do so tends to make code harder to read without sufficient benefit

barneygale pushed a commit to barneygale/cpython that referenced this pull request Jun 5, 2024
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
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.

3 participants