fix for a deadlock when using +RTS -hb with -prof -threaded
authorSimon Marlow <marlowsd@gmail.com>
Wed, 12 Oct 2011 14:38:09 +0000 (15:38 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 2 Nov 2011 16:34:03 +0000 (16:34 +0000)
rts/sm/GC.c

index 2252cfc..b97ff12 100644 (file)
@@ -407,8 +407,11 @@ GarbageCollect (rtsBool force_major_gc,
   // We call processHeapClosureForDead() on every closure destroyed during
   // the current garbage collection, so we invoke LdvCensusForDead().
   if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_LDV
-      || RtsFlags.ProfFlags.bioSelector != NULL)
-    LdvCensusForDead(N);
+      || RtsFlags.ProfFlags.bioSelector != NULL) {
+      RELEASE_SM_LOCK; // LdvCensusForDead may need to take the lock
+      LdvCensusForDead(N);
+      ACQUIRE_SM_LOCK;
+  }
 #endif
 
   // NO MORE EVACUATION AFTER THIS POINT!