summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-11-05 15:05:42 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-11-05 15:05:42 +0000
commit4760739d3176176d9ecb2af2212efb9e11ae2940 (patch)
treef96dbc5c827a5f326700cda651736ab6c0985fd3 /rts/Schedule.c
parent840eb5b9b8894281e414d78cdbe037bc7b458e74 (diff)
downloadhaskell-4760739d3176176d9ecb2af2212efb9e11ae2940.tar.gz
deadlock fix: reset the flag *after* checking the blackhole queue
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 8ab964dcb3..569c3d0845 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -934,8 +934,13 @@ scheduleCheckBlackHoles (Capability *cap)
{
ACQUIRE_LOCK(&sched_mutex);
if ( blackholes_need_checking ) {
- checkBlackHoles(cap);
blackholes_need_checking = rtsFalse;
+ // important that we reset the flag *before* checking the
+ // blackhole queue, otherwise we could get deadlock. This
+ // happens as follows: we wake up a thread that
+ // immediately runs on another Capability, blocks on a
+ // blackhole, and then we reset the blackholes_need_checking flag.
+ checkBlackHoles(cap);
}
RELEASE_LOCK(&sched_mutex);
}