gh-129824: fix data races in subinterpreters under TSAN by kumaraditya303 · Pull Request #135794 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

gh-129824: fix data races in subinterpreters under TSAN #135794

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

Merged
merged 6 commits into from
Jul 4, 2025

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jun 21, 2025

This fixes the data races in typeobject.c in subinterpreters under free-threading. The type flags are only modified in the main interpreter as all static types are first initialized in main interpreter. With the fix the test_interpreter_pool tests have no data races in typeobject.c under TSAN (there are still some unrelated data races in module exec like posix and struct).

@kumaraditya303 kumaraditya303 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 23, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit be846e8 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F135794%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 23, 2025
@kumaraditya303
Copy link
Contributor Author

kumaraditya303 commented Jun 25, 2025

This also fixes #116909 so more of test_capi tests can be enabled under free-threading TSAN (will do in follow up).

@kumaraditya303 kumaraditya303 requested a review from colesbury July 2, 2025 12:57
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.

This looks okay to me, but I don't understand the interaction between type_ready and subinterpreters very well, so I'd appreciate @ericsnowcurrently's review.

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

Mostly LGTM. I've left one mild suggestion and I'll leave it up to you.

FWIW, the relationship with subinterpreters is that the builtin types are "initialized" multiple times. There are certain things that only need to be done the first time, when the main interpreter is initialized, and some that need to be done for each interpreter. This is reflected by "initial".

@kumaraditya303 kumaraditya303 enabled auto-merge (squash) July 4, 2025 03:31
@kumaraditya303 kumaraditya303 added the needs backport to 3.14 bugs and security fixes label Jul 4, 2025
@kumaraditya303 kumaraditya303 merged commit b582d75 into python:main Jul 4, 2025
41 checks passed
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 4, 2025
…GH-135794)

This fixes the data races in typeobject.c in subinterpreters under free-threading. The type flags and slots are only modified in the main interpreter as all static types are first initialised in main interpreter.
(cherry picked from commit b582d75)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Jul 4, 2025

GH-136266 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jul 4, 2025
@kumaraditya303 kumaraditya303 deleted the interppool branch July 4, 2025 03:52
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.

4 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.