From b1b55be16f901f1eb67937560379fa9a75c88581 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Wed, 9 Dec 2020 23:10:22 -0500
Subject: [PATCH] nonmoving: Don't push objects during deadlock detect GC

Previously we would push large objects and compact regions to the mark
queue during the deadlock detect GC, resulting in failure to detect
deadlocks.
---
 rts/sm/Evac.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c
index 31965b7bde7e..bee6e583dcd8 100644
--- a/rts/sm/Evac.c
+++ b/rts/sm/Evac.c
@@ -441,7 +441,9 @@ evacuate_large(StgPtr p)
       __atomic_fetch_or(&bd->flags, BF_NONMOVING, __ATOMIC_ACQ_REL);
 
       // See Note [Non-moving GC: Marking evacuated objects].
-      markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure *) p);
+      if (major_gc && !deadlock_detect_gc) {
+          markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure *) p);
+      }
   }
   initBdescr(bd, new_gen, new_gen->to);
 
@@ -598,7 +600,9 @@ evacuate_compact (StgPtr p)
       __atomic_fetch_or(&bd->flags, BF_NONMOVING, __ATOMIC_RELAXED);
 
       // See Note [Non-moving GC: Marking evacuated objects].
-      markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure *) str);
+      if (major_gc && !deadlock_detect_gc) {
+          markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure *) str);
+      }
     }
     initBdescr(bd, new_gen, new_gen->to);
 
-- 
GitLab