https://github.com/python/cpython/commit/4ea3c1a04747978361b497798428423cbb6a7146
commit: 4ea3c1a04747978361b497798428423cbb6a7146
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2025-12-19T17:33:49-05:00
summary:

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.

files:
M Objects/genobject.c

diff --git a/Objects/genobject.c b/Objects/genobject.c
index 508d215a0cfe64..1e59d89f5ce85f 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);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to