Skip to content

Commit 4847114

Browse files
LindaSummermiss-islington
authored andcommitted
gh-154937: Fix _thread._shutdown() racing with _thread.start_joinable_thread on ThreadHandle.ident (GH-155085)
(cherry picked from commit a4095ee) Co-authored-by: Edward Xu <xuxiangad@gmail.com>
1 parent f85d8e4 commit 4847114

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
@@ -2349,7 +2349,7 @@ thread_shutdown(PyObject *self, PyObject *args)
23492349
struct llist_node *node;
23502350
llist_for_each_safe(node, &state->shutdown_handles) {
23512351
ThreadHandle *cur = llist_data(node, ThreadHandle, shutdown_node);
2352-
if (cur->ident != ident) {
2352+
if (ThreadHandle_ident(cur) != ident) {
23532353
ThreadHandle_incref(cur);
23542354
handle = cur;
23552355
break;

0 commit comments

Comments
 (0)