Skip to content

Commit 4bec1e7

Browse files
committed
Use sequential memory ordering in _testembed.
I'm seeing some odd failures in CI. I doubt this is the cause, but this looks like it could be its own bug.
1 parent a538acc commit 4bec1e7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Programs/_testembed.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ do_tstate_ensure(void *arg)
27102710
PyThreadState_Release(tokens[1]);
27112711
PyThreadState_Release(tokens[0]);
27122712
PyInterpreterGuard_Close(guard);
2713-
data->done = 1;
2713+
_Py_atomic_store_int(&data->done, 1);
27142714
}
27152715

27162716
static int
@@ -2731,7 +2731,7 @@ test_thread_state_ensure(void)
27312731
// have to worry about the interpreter shutting down before
27322732
// we finalize.
27332733
Py_Finalize();
2734-
assert(data.done == 1);
2734+
assert(_Py_atomic_load_int(&data.done) == 1);
27352735
PyThread_join_thread(handle);
27362736
return 0;
27372737
}
@@ -2774,7 +2774,7 @@ do_tstate_ensure_from_view(void *arg)
27742774
_PyEvent_Notify(&data->event);
27752775
int res = PyRun_SimpleString(THREAD_CODE);
27762776
assert(res == 0);
2777-
data->done = 1;
2777+
_Py_atomic_store_int(&data->done, 1);
27782778
PyThreadState_Release(token);
27792779
}
27802780

@@ -2796,7 +2796,7 @@ test_thread_state_ensure_from_view(void)
27962796

27972797
PyEvent_Wait(&data.event);
27982798
Py_Finalize();
2799-
assert(data.done == 1);
2799+
assert(_Py_atomic_load_int(&data.done) == 1);
28002800
PyThread_join_thread(handle);
28012801
return 0;
28022802
}

0 commit comments

Comments
 (0)