mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761) (GH-127173)
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 ca3ea9ad05
)
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
This commit is contained in:
parent
29648980d4
commit
f1e7424802
4 changed files with 40 additions and 1 deletions
|
@ -1219,6 +1219,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
|||
if (ident == PYTHREAD_INVALID_THREAD_ID) {
|
||||
PyErr_SetString(ThreadError, "can't start new thread");
|
||||
PyThreadState_Clear(boot->tstate);
|
||||
PyThreadState_Delete(boot->tstate);
|
||||
thread_bootstate_free(boot, 1);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue