mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +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
|
|
@ -2238,7 +2238,8 @@ stop_the_world(struct _stoptheworld_state *stw)
|
|||
}
|
||||
|
||||
PyTime_t wait_ns = 1000*1000; // 1ms (arbitrary, may need tuning)
|
||||
if (PyEvent_WaitTimed(&stw->stop_event, wait_ns)) {
|
||||
int detach = 0;
|
||||
if (PyEvent_WaitTimed(&stw->stop_event, wait_ns, detach)) {
|
||||
assert(stw->thread_countdown == 0);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue