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>
This commit is contained in:
Radislav Chugunov 2024-11-22 22:20:07 +03:00 committed by GitHub
parent a264637654
commit ca3ea9ad05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 1 deletions

View file

@ -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);