cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-120321: Make gi_frame_state transitions atomic in FT build

Open colesbury opened this issue 2 weeks ago • 1 comments

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
  • Issue: gh-120321

colesbury avatar Dec 11 '25 20:12 colesbury

:robot: New build scheduled with the buildbot fleet by @colesbury for commit ac3974df0bef87b3471c6226d5d7f22dd071af32 :robot:

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F142599%2Fmerge

If you want to schedule another build, you need to add the :hammer: test-with-refleak-buildbots label again.

bedevere-bot avatar Dec 12 '25 17:12 bedevere-bot

The changes look good.

I'm concerned about the complexity of this for such an obscure use case, but I can't suggest a better way of doing it.

markshannon avatar Dec 18 '25 12:12 markshannon