[3.14] gh-134381: Fix RuntimeError when starting not-yet started Thread after fork (gh-134514) (gh-134596)

(cherry picked from commit 9a2346df86)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-23 21:49:13 +02:00 committed by GitHub
parent 6e60586175
commit 09a34f1f65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 0 deletions

View file

@ -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.