FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] gh-137400: Fix a crash when disabling profiling across all threads (gh-137471) by miss-islington · Pull Request #137648 · python/cpython · GitHub

/ cpython Public

[3.14] gh-137400: Fix a crash when disabling profiling across all threads (gh-137471) - #137648

Merged
hugovk merged 1 commit into
python:3.14from
miss-islington:backport-3626928-3.14
Aug 12, 2025
Merged

[3.14] gh-137400: Fix a crash when disabling profiling across all threads (gh-137471)#137648
hugovk merged 1 commit into
python:3.14from
miss-islington:backport-3626928-3.14

Conversation

miss-islington commented Aug 11, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

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 colesbury@gmail.com

…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 <colesbury@gmail.com>

Copy link
Copy Markdown
Contributor

@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.​​​​​​​​​​​​​​​​

hugovk commented Aug 12, 2025

Copy link
Copy Markdown
Member

Let's go with this smaller fix for 3.14.0 RC2. Thanks!

hugovk merged commit 4ebd928 into python:3.14 Aug 12, 2025
84 of 86 checks passed
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
miss-islington deleted the backport-3626928-3.14 branch January 2, 2026 18:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL