mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-118332: Fix deadlock involving stop the world (#118412)
Avoid detaching thread state when stopping the world. When re-attaching the thread state, the thread would attempt to resume the top-most critical section, which might now be held by a thread paused for our stop-the-world request.
This commit is contained in:
parent
4a1cf66c5c
commit
b2c3b70c71
5 changed files with 96 additions and 7 deletions
|
|
@ -501,7 +501,8 @@ ThreadHandle_join(ThreadHandle *self, PyTime_t timeout_ns)
|
|||
|
||||
// Wait until the deadline for the thread to exit.
|
||||
PyTime_t deadline = timeout_ns != -1 ? _PyDeadline_Init(timeout_ns) : 0;
|
||||
while (!PyEvent_WaitTimed(&self->thread_is_exiting, timeout_ns)) {
|
||||
int detach = 1;
|
||||
while (!PyEvent_WaitTimed(&self->thread_is_exiting, timeout_ns, detach)) {
|
||||
if (deadline) {
|
||||
// _PyDeadline_Get will return a negative value if the deadline has
|
||||
// been exceeded.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue