Skip to content

Commit 4ea3c1a

Browse files
authored
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.
1 parent 08bc03f commit 4ea3c1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Objects/genobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ _PyGen_Finalize(PyObject *self)
153153
static void
154154
gen_clear_frame(PyGenObject *gen)
155155
{
156-
assert(gen->gi_frame_state == FRAME_CLEARED);
156+
assert(FT_ATOMIC_LOAD_INT8_RELAXED(gen->gi_frame_state) == FRAME_CLEARED);
157157
_PyInterpreterFrame *frame = &gen->gi_iframe;
158158
frame->previous = NULL;
159159
_PyFrame_ClearExceptCode(frame);

0 commit comments

Comments
 (0)