8000 gh-116396: Pass "detached_state" argument to tstate_set_detached (#11… · python/cpython@834bf57 · GitHub
[go: up one dir, main page]

Skip to content

Commit 834bf57

Browse files
authored
gh-116396: Pass "detached_state" argument to tstate_set_detached (#116398)
The stop-the-world code was incorrectly setting suspended threads' states to _Py_THREAD_DETACHED instead of _Py_THREAD_SUSPENDED.
1 parent d9bcdda commit 834bf57

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/pystate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ _PyInterpreterState_Clear(PyThreadState *tstate)
903903

904904

905905
static inline void tstate_deactivate(PyThreadState *tstate);
906-
static void tstate_set_detached(PyThreadState *tstate);
906+
static void tstate_set_detached(PyThreadState *tstate, int detached_state);
907907
static void zapthreads(PyInterpreterState *interp);
908908

909909
void
@@ -1686,7 +1686,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
16861686
#ifdef Py_GIL_DISABLED
16871687
_Py_qsbr_detach(((_PyThreadStateImpl *)tstate)->qsbr);
16881688
#endif
1689-
tstate_set_detached(tstate);
1689+
tstate_set_detached(tstate, _Py_THREAD_DETACHED);
16901690
tstate_delete_common(tstate);
16911691
current_fast_clear(tstate->interp->runtime);
16921692
_PyEval_ReleaseLock(tstate->interp, NULL);
@@ -1859,13 +1859,13 @@ tstate_try_attach(PyThreadState *tstate)
18591859
}
18601860

18611861
static void
1862-
tstate_set_detached(PyThreadState *tstate)
1862+
tstate_set_detached(PyThreadState *tstate, int detached_state)
18631863
{
18641864
assert(tstate->state == _Py_THREAD_ATTACHED);
18651865
#ifdef Py_GIL_DISABLED
1866-
_Py_atomic_store_int(&tstate->state, _Py_THREAD_DETACHED);
1866+
_Py_atomic_store_int(&tstate->state, detached_state);
18671867
#else
1868-
tstate->state = _Py_THREAD_DETACHED;
1868+
tstate->state = detached_state;
18691869
#endif
18701870
}
18711871

@@ -1935,7 +1935,7 @@ detach_thread(PyThreadState *tstate, int detached_state)
19351935
_Py_qsbr_detach(((_PyThreadStateImpl *)tstate)->qsbr);
19361936
#endif
19371937
tstate_deactivate(tstate);
1938-
tstate_set_detached(tstate);
1938+
tstate_set_detached(tstate, detached_state);
19391939
current_fast_clear(&_PyRuntime);
19401940
_PyEval_ReleaseLock(tstate->interp, tstate);
19411941
}

0 commit comments

Comments
 (0)
0