Skip to content

gh-136870: fix race in PyThreadState_Clear on sys_tracing_threads - #136951

Merged
kumaraditya303 merged 1 commit into
python:mainfrom
kumaraditya303:ts-clear-monitoring
Jul 21, 2025
Merged

gh-136870: fix race in PyThreadState_Clear on sys_tracing_threads#136951
kumaraditya303 merged 1 commit into
python:mainfrom
kumaraditya303:ts-clear-monitoring

Conversation

@kumaraditya303

@kumaraditya303kumaraditya303 commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

In free-threading multiple threads can be cleared concurrently as such the modifications on sys_tracing_threads should be done while holding the profile lock otherwise it can race with other threads setting up profiling.

@ZeroIntensity

Copy link
Copy Markdown
Member

No news entry? This is fixing public APIs.

@kumaraditya303

kumaraditya303 commented Jul 21, 2025

Copy link
Copy Markdown
ContributorAuthor

No news entry? This is fixing public APIs.

I don't think news entries for data race fixes like this one are useful for user, we haven't been adding news for most of these changes unless it's a large change like fixing all races of a module.

@kumaraditya303
kumaraditya303 merged commit f183996 into python:mainJul 21, 2025
52 checks passed
@miss-islington-app

Copy link
Copy Markdown

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 21, 2025
…ng_threads` (pythonGH-136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
(cherry picked from commit f183996)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
@bedevere-app

Copy link
Copy Markdown

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

@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Jul 21, 2025
@kumaraditya303
kumaraditya303 deleted the ts-clear-monitoring branch July 21, 2025 20:39
kumaraditya303 added a commit that referenced this pull request Jul 21, 2025
…ing_threads` (GH-136951) (#136953)
gh-136870: fix data race in `PyThreadState_Clear` on `sys_tracing_threads` (GH-136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
(cherry picked from commit f183996)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…ng_threads` (python#136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…ng_threads` (python#136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
kumaraditya303 added a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…s_tracing_threads` (pythonGH-136951) (python#136953)
pythongh-136870: fix data race in `PyThreadState_Clear` on `sys_tracing_threads` (pythonGH-136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
(cherry picked from commit f183996)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Sign up for freeto 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

@kumaraditya303@ZeroIntensity@colesbury