gh-120321: Make gi_frame_state transitions atomic in FT build
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
: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.
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.