GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

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

Uh oh!

There was an error while loading. Please reload this page.

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 [email protected]

  • Issue: sys._setprofileallthreads race condition #137400

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@colesbury @miss-islington
pythongh-137400: Fix a crash when disabling profiling across all thre…
77f9ca6
…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]>
@bedevere-app bedevere-app Bot added the awaiting review label Aug 11, 2025
This was referenced Aug 11, 2025
sys._setprofileallthreads race condition #137400
Closed
gh-137400: Fix a crash when disabling profiling across all threads #137471
Merged
@bedevere-app bedevere-app Bot added the topic-free-threading label Aug 11, 2025
colesbury
colesbury approved these changes Aug 11, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 11, 2025
@colesbury
colesbury requested a review from kumaraditya303 August 11, 2025 15:47
kumaraditya303
kumaraditya303 approved these changes Aug 11, 2025
View reviewed changes
@colesbury colesbury assigned hugovk Aug 11, 2025
@colesbury

colesbury commented Aug 11, 2025

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Aug 12, 2025

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk
hugovk merged commit 4ebd928 into python:3.14 Aug 12, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 12, 2025
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
@miss-islington @colesbury @kumaraditya303
[3.14] pythongh-137400: Fix a crash when disabling profiling across a…
90dc6d8
…ll threads (pythongh-137471) (python#137648)

Co-authored-by: Sam Gross <[email protected]>
@miss-islington
miss-islington deleted the backport-3626928-3.14 branch January 2, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@colesbury colesbury colesbury approved these changes
@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@hugovk hugovk

Labels

topic-free-threading

Projects

None yet

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.

4 participants

@miss-islington @colesbury @hugovk @kumaraditya303
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.