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: TSAN fix race on gstate->young.count #118313

Merged
merged 16 commits into from
Apr 29, 2024
Merged

Conversation

SonicField
Copy link
Contributor

@SonicField SonicField commented Apr 26, 2024

In gc_free_threading.c at line 1016 the gcstate->young.count is batch incremented via an atomic add. However, at 1162 the count is set to zero during garbage collection and that set is not atomic. This causes a race condition with the addition. Changing to an atomic set solves the race.

Copy link

cpython-cla-bot bot commented Apr 26, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Apr 26, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@SonicField SonicField changed the title hg-117657: TSAN fix race between atomic and none-atomic mutation of tate->young.… gh-117657: TSAN fix race between atomic and none-atomic mutation of tate->young.… Apr 26, 2024
@SonicField SonicField changed the title gh-117657: TSAN fix race between atomic and none-atomic mutation of tate->young.… gh-117657: TSAN fix race between atomic and none-atomic mutation of gstate->young.… Apr 26, 2024
@SonicField SonicField changed the title gh-117657: TSAN fix race between atomic and none-atomic mutation of gstate->young.… gh-117657: TSAN fix race on gstate->young.count Apr 26, 2024
@bedevere-app
Copy link

bedevere-app bot commented Apr 26, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@SonicField
Copy link
Contributor Author

@DinoV @mpage @colesbury Here is my first go at a pull request. I cannot figure out how to add you are reviewers; I don't think I have permissions to do so or some such.

@SonicField SonicField marked this pull request as ready for review April 26, 2024 12:12
@colesbury colesbury self-requested a review April 26, 2024 14:46
Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

Thanks Alex - I left a few comments below

Python/gc_free_threading.c Outdated Show resolved Hide resolved
Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

There are two compiler warnings (see the "Files changed" tab) and the NEWS file can be removed.

@SonicField
Copy link
Contributor Author

Hopefullt fixed the compiler warnings (my bad).

Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

Thanks Alex!

@colesbury colesbury enabled auto-merge (squash) April 29, 2024 19:53
@colesbury colesbury merged commit 2ba1aed into python:main Apr 29, 2024
34 checks passed
Yhg1s added a commit to Yhg1s/cpython that referenced this pull request Sep 29, 2024
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