GeezerVison is showing github.com — [3.14] gh-137400: Fix a crash when disabling profiling across all threads (gh-137471) by miss-islington · Pull Request #137648 · python/cpython
Conversation
miss-islington
commented
Aug 11, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
The PyEval_SetProfileAllThreads function and other related functions
had a race condition on tstate->c_profilefunc that could lead to a
crash when disable profiling or tracing on all threads while another
thread is starting to profile or trace a a call.
There are still potential crashes when threads exit concurrently with
profiling or tracing be enabled/disabled across all threads.
(cherry picked from commit 3626928)
Co-authored-by: Sam Gross [email protected]
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ads (pythongh-137471)
The `PyEval_SetProfileAllThreads` function and other related functions
had a race condition on `tstate->c_profilefunc` that could lead to a
crash when disable profiling or tracing on all threads while another
thread is starting to profile or trace a a call.
There are still potential crashes when threads exit concurrently with
profiling or tracing be enabled/disabled across all threads.
(cherry picked from commit 3626928)
Co-authored-by: Sam Gross <[email protected]>
This was referenced Aug 11, 2025
|
@hugovk
From @pablogsal's comment in #137400 (comment):
The worry we have is that this is going to segfault for a bunch of users, and we’ll burn a lot of effort trying to diagnose whether issues are caused by this bug or something else.
So it would be great to get it in 3.14.0 if possible, but we understand if that’s not possible or if you want to wait until the next release.
From our perspective, having users hit segfaults in production when using memray with Python 3.14.0 has the risk to create a significant support burden - we’d have to triage every crash report to determine if it’s this known issue or something new and given the nature of this problem that may be a pain to guide the user or even get a reproducer. Getting the fix into 3.14.0 would save both our users and ourselves from that pain.
That said, we appreciate the trade-offs involved here so if the bigger fix needs more time to bake, the smaller fix in 3.14.0 might be a reasonable compromise to at least prevent the segfaults, even if it doesn’t address all the thread-safety issues.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Let's go with this smaller fix for 3.14.0 RC2. Thanks!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.