diff options
author | Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> | 2024-11-22 22:20:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-22 21:20:07 +0200 |
commit | ca3ea9ad05c3d876a58463595e5b4228fda06936 (patch) | |
tree | 2e4cbfbc1aef5647a3a1f8977b8448141730e937 /Python/pystate.c | |
parent | a264637654f9d3ac3c140e66fd56ee32faf22431 (diff) | |
download | cpython-ca3ea9ad05c3d876a58463595e5b4228fda06936.tar.gz cpython-ca3ea9ad05c3d876a58463595e5b4228fda06936.zip |
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761)
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.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Python/pystate.c')
-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 975eb6d4fbd..3ceae229f75 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1779,7 +1779,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); |