Skip to content

Commit

Permalink
Fix a rare deadlock when the IO manager thread is slow to start up
Browse files Browse the repository at this point in the history
This fixes occasional failures of ffi002(threaded1) on a loaded
machine.
  • Loading branch information
simonmar committed Mar 9, 2010
1 parent 594eb91 commit f8a01fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rts/Capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,18 @@ shutdownCapability (Capability *cap, Task *task, rtsBool safe)
"thread(s) are involved in foreign calls, yielding");
cap->running_task = NULL;
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();
continue;
}

traceEventShutdown(cap);
RELEASE_LOCK(&cap->lock);
break;
Expand Down

0 comments on commit f8a01fb

Please sign in to comment.