From: Sam Gross Date: Fri, 19 Dec 2025 22:33:49 +0000 (-0500) Subject: gh-120321: Fix TSan reported race in gen_clear_frame (gh-142995) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ea3c1a04747978361b497798428423cbb6a7146;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Objects/genobject.c b/Objects/genobject.c index 508d215a0cfe..1e59d89f5ce8 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -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);