Commit f8a01fb3 authored by Simon Marlow's avatar Simon Marlow
Browse files

Fix a rare deadlock when the IO manager thread is slow to start up

This fixes occasional failures of ffi002(threaded1) on a loaded
machine.
parent 594eb917
...@@ -786,10 +786,18 @@ shutdownCapability (Capability *cap, Task *task, rtsBool safe) ...@@ -786,10 +786,18 @@ shutdownCapability (Capability *cap, Task *task, rtsBool safe)
"thread(s) are involved in foreign calls, yielding"); "thread(s) are involved in foreign calls, yielding");
cap->running_task = NULL; cap->running_task = NULL;
RELEASE_LOCK(&cap->lock); RELEASE_LOCK(&cap->lock);
// The IO manager thread might have been slow to start up,
// so the first attempt to kill it might not have
// succeeded. Just in case, try again - the kill message
// will only be sent once.
//
// To reproduce this deadlock: run ffi002(threaded1)
// repeatedly on a loaded machine.
ioManagerDie();
yieldThread(); yieldThread();
continue; continue;
} }
traceEventShutdown(cap); traceEventShutdown(cap);
RELEASE_LOCK(&cap->lock); RELEASE_LOCK(&cap->lock);
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment