◐ Shell
clean mode source ↗

gh-137400: Fix thread-safety issues when profiling all threads by colesbury · Pull Request #137518 · python/cpython

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.

@bedevere-app Bot mentioned this pull request

Aug 7, 2025

@colesbury

@colesbury colesbury changed the title gh-137400: Fix a thread-safety issues when profiling all threads gh-137400: Fix thread-safety issues when profiling all threads

Aug 7, 2025

@colesbury

@colesbury

@colesbury colesbury marked this pull request as ready for review

August 7, 2025 16:15

@colesbury

gaogaotiantian

ZeroIntensity

kumaraditya303

kumaraditya303

Co-authored-by: Kumar Aditya <kumaraditya@python.org>

kumaraditya303

kumaraditya303

@colesbury

ZeroIntensity

kumaraditya303

Co-authored-by: Kumar Aditya <kumaraditya@python.org>

kumaraditya303

@colesbury colesbury deleted the gh-137400-now-with-fewer-crashes branch

August 13, 2025 18:15

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

Aug 13, 2025
…hreads (pythongh-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.
(cherry picked from commit a10152f)

Co-authored-by: Sam Gross <colesbury@gmail.com>

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

Aug 13, 2025
…hreads (pythongh-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.
(cherry picked from commit a10152f)

Co-authored-by: Sam Gross <colesbury@gmail.com>

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

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

colesbury added a commit that referenced this pull request

Oct 7, 2025
…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 a10152f)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>

colesbury added a commit that referenced this pull request

Oct 9, 2025
…gh-137518) (gh-137733)

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 a10152f)