Skip to content

Commit a4095ee

Browse files
authored
gh-154937: Fix _thread._shutdown() racing with _thread.start_joinable_thread on ThreadHandle.ident (#155085)
1 parent 5918085 commit a4095ee

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a data race on thread handle identifiers when ``_thread._shutdown()``
2+
runs concurrently with the startup of non-daemon threads in the
3+
:term:`free-threaded build`.

Modules/_threadmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ thread_shutdown(PyObject *self, PyObject *args)
24132413
struct llist_node *node;
24142414
llist_for_each_safe(node, &state->shutdown_handles) {
24152415
ThreadHandle *cur = llist_data(node, ThreadHandle, shutdown_node);
2416-
if (cur->ident != ident) {
2416+
if (ThreadHandle_ident(cur) != ident) {
24172417
ThreadHandle_incref(cur);
24182418
handle = cur;
24192419
break;

0 commit comments

Comments
 (0)