]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-137400: Fix thread-safety issues when profiling all threads (gh-137518...
authorSam Gross <colesbury@gmail.com>
Tue, 7 Oct 2025 17:45:23 +0000 (13:45 -0400)
committerGitHub <noreply@github.com>
Tue, 7 Oct 2025 17:45:23 +0000 (13:45 -0400)
commitfb699effbfd9b34a1b2f3ee10338f1f4279509bb
treed3b57a5094203435f5a393d877ee8f2d57d7dd90
parentc1cb785ebd0859a3c560091c5bb4f7f559656b44
[3.14] gh-137400: Fix thread-safety issues when profiling all threads (gh-137518) (gh-137730)

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.
(cherry picked from commit a10152f8fd0f4b291e53d646cffe22fbeec73e1e)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
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