◐ Shell
clean mode source ↗

[3.13] gh-137400: Fix a crash when disabling profiling across all threads (gh-137471) by colesbury · Pull Request #137649 · python/cpython

…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>