◐ Shell
clean mode source ↗

gh-137400: Fix a crash when disabling profiling across all threads by colesbury · Pull Request #137471 · python/cpython

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.

@bedevere-app Bot mentioned this pull request

Aug 6, 2025

@colesbury colesbury marked this pull request as ready for review

August 7, 2025 18:55

kumaraditya303

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Aug 11, 2025
…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>

colesbury added a commit to colesbury/cpython that referenced this pull request

Aug 11, 2025
…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>

colesbury added a commit that referenced this pull request

Aug 11, 2025
…eads (gh-137471) (gh-137649)

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)

hugovk pushed a commit that referenced this pull request

Aug 12, 2025

maurycy added a commit to maurycy/cpython that referenced this pull request

Aug 12, 2025

Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request

Aug 19, 2025
…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.

kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request

Sep 9, 2025