Skip to content

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

Merged
colesbury merged 1 commit into
python:3.13from
colesbury:backport-3626928-3.13
Aug 11, 2025
Merged

colesbury merged 1 commit into
python:3.13from
colesbury:backport-3626928-3.13

Conversation

@colesbury

@colesbury colesbury commented Aug 11, 2025 •

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)

…ll threads (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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant