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 erroneous TSAN reports of data races in _PySeqLock #117955

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

mpage
Copy link
Contributor

@mpage mpage commented Apr 17, 2024

TSAN reports a couple of data races between the compare/exchange in _PySeqLock_LockWrite:

else if (_Py_atomic_compare_exchange_uint32(&seqlock->sequence, &prev, prev + 1)) {

and the non-atomic loads in _PySeqLock_AbandonWrite (example race):

cpython/Python/lock.c

Lines 493 to 495 in a23fa33

void _PySeqLock_AbandonWrite(_PySeqLock *seqlock)
{
uint32_t new_seq = seqlock->sequence - 1;

and _PySeqLock_UnlockWrite (example race):

cpython/Python/lock.c

Lines 500 to 502 in a23fa33

void _PySeqLock_UnlockWrite(_PySeqLock *seqlock)
{
uint32_t new_seq = seqlock->sequence + 1;

This is another instance of TSAN incorrectly modeling failed compare/exchange as a write instead of a load.

TSAN reports a couple of data races between the compare/exchange in
`_PySeqLock_LockWrite` and the non-atomic loads in `_PySeqLock_{Abandon,Unlock}Write`.
This is another instance of TSAN incorrectly modeling failed compare/exchange
as a write instead of a load.
@mpage mpage requested review from DinoV and colesbury April 17, 2024 04:40
@mpage mpage marked this pull request as ready for review April 17, 2024 05:40
Copy link
Contributor

@DinoV DinoV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

cpython-cla-bot bot commented Apr 17, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@DinoV DinoV enabled auto-merge (squash) April 17, 2024 16:45
@DinoV DinoV merged commit 0d29302 into python:main Apr 17, 2024
34 checks passed
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