]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-137400: Fix thread-safety issues when profiling all threads (gh-137518)
authorSam Gross <colesbury@gmail.com>
Wed, 13 Aug 2025 18:15:12 +0000 (14:15 -0400)
committerGitHub <noreply@github.com>
Wed, 13 Aug 2025 18:15:12 +0000 (14:15 -0400)
commita10152f8fd0f4b291e53d646cffe22fbeec73e1e
tree1d6bf8a7bec013e36c8630b0f0c14bcc72f5b8e2
parent923d68655b6730f297106b2e79c964981fc3be7c
gh-137400: Fix thread-safety issues when profiling all threads (gh-137518)

There were a few thread-safety issues when profiling or tracing all
threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads:

* The loop over thread states could crash if a thread exits concurrently
  (in both the free threading and default build)
* The modification of `c_profilefunc` and `c_tracefunc` wasn't
  thread-safe on the free threading build.
Include/internal/pycore_ceval.h
Include/internal/pycore_interp_structs.h
Lib/test/test_free_threading/test_monitoring.py
Misc/NEWS.d/next/Core_and_Builtins/2025-08-07-09-52-19.gh-issue-137400.AK1dy-.rst [new file with mode: 0644]
Python/bytecodes.c
Python/ceval.c
Python/generated_cases.c.h
Python/instrumentation.c
Python/legacy_tracing.c
Python/pystate.c
Python/sysmodule.c