gh-120321: Fix TSan reported race in gen_clear_frame (gh-142995)

TSan treats compare-exchanges that fail as if they are writes
so there is a false positive with the read of gi_frame_state in
gen_close.
This commit is contained in:
Sam Gross 2025-12-19 17:33:49 -05:00 committed by GitHub
parent 08bc03ff2a
commit 4ea3c1a047
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -153,7 +153,7 @@ _PyGen_Finalize(PyObject *self)
static void
gen_clear_frame(PyGenObject *gen)
{
assert(gen->gi_frame_state == FRAME_CLEARED);
assert(FT_ATOMIC_LOAD_INT8_RELAXED(gen->gi_frame_state) == FRAME_CLEARED);
_PyInterpreterFrame *frame = &gen->gi_iframe;
frame->previous = NULL;
_PyFrame_ClearExceptCode(frame);