mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[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 ca3ea9ad05
)
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
This commit is contained in:
parent
950daf8765
commit
75ef92da29
4 changed files with 40 additions and 1 deletions
|
@ -421,6 +421,7 @@ ThreadHandle_start(ThreadHandle *self, PyObject *func, PyObject *args,
|
|||
PyThread_handle_t os_handle;
|
||||
if (PyThread_start_joinable_thread(thread_run, boot, &ident, &os_handle)) {
|
||||
PyThreadState_Clear(boot->tstate);
|
||||
PyThreadState_Delete(boot->tstate);
|
||||
thread_bootstate_free(boot, 1);
|
||||
PyErr_SetString(ThreadError, "can't start new thread");
|
||||
goto start_failed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue