diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2024-11-22 19:55:44 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-22 19:55:44 (GMT) |
| commit | 75ef92da291247fd9d21ec26bd22bf8055b5f330 (patch) | |
| tree | ac712250b2a8d3a08a6a770ad1265aa649cd685c /Python | |
| parent | 950daf8765d5ea026112c2affccc9ae06ee90827 (diff) | |
| download | cpython-75ef92da291247fd9d21ec26bd22bf8055b5f330.zip cpython-75ef92da291247fd9d21ec26bd22bf8055b5f330.tar.gz cpython-75ef92da291247fd9d21ec26bd22bf8055b5f330.tar.bz2 | |
[3.13] gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761) (GH-127171)
If Python fails to start newly created thread
due to failure of underlying PyThread_start_new_thread() call,
its state should be removed from interpreter' thread states list
to avoid its double cleanup.
(cherry picked from commit ca3ea9ad05c3d876a58463595e5b4228fda06936)
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/pystate.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 960895e..528847d 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1811,7 +1811,9 @@ tstate_delete_common(PyThreadState *tstate, int release_gil) if (tstate->_status.bound_gilstate) { unbind_gilstate_tstate(tstate); } - unbind_tstate(tstate); + if (tstate->_status.bound) { + unbind_tstate(tstate); + } // XXX Move to PyThreadState_Clear()? clear_datastack(tstate); |
