summaryrefslogtreecommitdiffstats
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-05-23 19:49:13 (GMT)
committerGitHub <noreply@github.com>2025-05-23 19:49:13 (GMT)
commit09a34f1f659cd66c380353cf9b8b0247789128cc (patch)
treea57585219efecfb10c2cf70d6664196f09729b59 /Modules/_threadmodule.c
parent6e605861751eb0f8cca3836e2eadd34faf6a7ad2 (diff)
downloadcpython-09a34f1f659cd66c380353cf9b8b0247789128cc.zip
cpython-09a34f1f659cd66c380353cf9b8b0247789128cc.tar.gz
cpython-09a34f1f659cd66c380353cf9b8b0247789128cc.tar.bz2
[3.14] gh-134381: Fix RuntimeError when starting not-yet started Thread after fork (gh-134514) (gh-134596)
(cherry picked from commit 9a2346df861f26d5f8d054ad2f9c37134dee3822) Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r--Modules/_threadmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index f676659..73739d2 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -281,6 +281,12 @@ _PyThread_AfterFork(struct _pythread_runtime_state *state)
continue;
}
+ // Keep handles for threads that have not been started yet. They are
+ // safe to start in the child process.
+ if (handle->state == THREAD_HANDLE_NOT_STARTED) {
+ continue;
+ }
+
// Mark all threads as done. Any attempts to join or detach the
// underlying OS thread (if any) could crash. We are the only thread;
// it's safe to set this non-atomically.