We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6087f49 commit 4eb4ae6Copy full SHA for 4eb4ae6
Python/pystate.c
@@ -829,11 +829,16 @@ new_threadstate(PyInterpreterState *interp)
829
// Every valid interpreter must have at least one thread.
830
assert(id > 1);
831
assert(old_head->prev == NULL);
832
-
+ // Unlock before allocating memory.
833
+ HEAD_UNLOCK(runtime);
834
tstate = alloc_threadstate();
835
+ HEAD_LOCK(runtime);
836
if (tstate == NULL) {
837
goto error;
838
}
839
+ // Read interp->threads.head again as another thread could
840
+ // have created a thread state while we were allocating memory.
841
+ old_head = interp->threads.head;
842
// Set to _PyThreadState_INIT.
843
memcpy(tstate,
844
&initial._main_interpreter._initial_thread,
0 commit comments