]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-137400: Fix a crash when disabling profiling across all threads (gh-137471)
authorSam Gross <colesbury@gmail.com>
Mon, 11 Aug 2025 15:41:44 +0000 (11:41 -0400)
committerGitHub <noreply@github.com>
Mon, 11 Aug 2025 15:41:44 +0000 (11:41 -0400)
commit362692852f13cdd1d33cc7ed35c0cbac7af1a785
tree6ab63b8277da3624d869f7f5c7911b6c9a0c6f97
parentdeb0020e3d478fa72104b82e2ba1a1c0c6eb4eae
gh-137400: Fix a crash when disabling profiling across all threads (gh-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.
Lib/test/test_free_threading/test_monitoring.py
Misc/NEWS.d/next/Core_and_Builtins/2025-08-06-15-39-54.gh-issue-137400.xIw0zs.rst [new file with mode: 0644]
Python/legacy_tracing.c