diff --git a/Python/ceval.c b/Python/ceval.c index 728a8f7de7..94e757c6f5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2707,9 +2707,7 @@ PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *arg) _PyObjectQueue *queue = NULL; - _PyMutex_lock(&_PyRuntime.stoptheworld_mutex); _PyRuntimeState_StopTheWorld(&_PyRuntime); - HEAD_LOCK(runtime); PyThreadState* ts = PyInterpreterState_ThreadHead(interp); while (ts) { @@ -2720,9 +2718,7 @@ PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *arg) ts = PyThreadState_Next(ts); } HEAD_UNLOCK(runtime); - _PyRuntimeState_StartTheWorld(&_PyRuntime); - _PyMutex_unlock(&_PyRuntime.stoptheworld_mutex); PyObject *old_traceobj; _PyObjectQueue_ForEach(&queue, old_traceobj) { diff --git a/Python/pystate.c b/Python/pystate.c index c15b22c16c..63b55d68ca 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1764,6 +1764,7 @@ _PyThread_CurrentFrames(void) * need to grab head_mutex for the duration. */ _PyRuntimeState *runtime = tstate->interp->runtime; + _PyRuntimeState_StopTheWorld(runtime); HEAD_LOCK(runtime); PyInterpreterState *i; for (i = runtime->interpreters.head; i != NULL; i = i->next) { @@ -1797,6 +1798,7 @@ _PyThread_CurrentFrames(void) done: HEAD_UNLOCK(runtime); + _PyRuntimeState_StartTheWorld(runtime); return result; } @@ -1823,6 +1825,7 @@ _PyThread_CurrentExceptions(void) * need to grab head_mutex for the duration. */ _PyRuntimeState *runtime = tstate->interp->runtime; + _PyRuntimeState_StopTheWorld(runtime); HEAD_LOCK(runtime); PyInterpreterState *i; for (i = runtime->interpreters.head; i != NULL; i = i->next) { @@ -1856,6 +1859,7 @@ _PyThread_CurrentExceptions(void) done: HEAD_UNLOCK(runtime); + _PyRuntimeState_StartTheWorld(runtime); return result; }