]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-120321: Make gi_frame_state transitions atomic in FT build (gh-142599)
authorSam Gross <colesbury@gmail.com>
Fri, 19 Dec 2025 19:10:37 +0000 (14:10 -0500)
committerGitHub <noreply@github.com>
Fri, 19 Dec 2025 19:10:37 +0000 (19:10 +0000)
commit08bc03ff2a5545a165ba57f4ca73b8ff705dc757
tree29422536ebed368e23524bfe57e23a0cb6f7e0e6
parente2a7db717507a66b49bb796391530147b3acab93
gh-120321: Make gi_frame_state transitions atomic in FT build (gh-142599)

This makes generator frame state transitions atomic in the free
threading build, which avoids segfaults when trying to execute
a generator from multiple threads concurrently.

There are still a few operations that aren't thread-safe and may crash
if performed concurrently on the same generator/coroutine:

 * Accessing gi_yieldfrom/cr_await/ag_await
 * Accessing gi_frame/cr_frame/ag_frame
 * Async generator operations
16 files changed:
Include/cpython/pyatomic.h
Include/cpython/pyatomic_gcc.h
Include/cpython/pyatomic_msc.h
Include/cpython/pyatomic_std.h
Include/internal/pycore_pyatomic_ft_wrappers.h
Include/internal/pycore_tstate.h
Include/internal/pycore_uop_ids.h
Include/internal/pycore_uop_metadata.h
Lib/test/test_free_threading/test_generators.py
Objects/genobject.c
Python/bytecodes.c
Python/ceval.c
Python/ceval_macros.h
Python/executor_cases.c.h
Python/generated_cases.c.h
Tools/cases_generator/analyzer.py