From 4123b929e477d333290c958628d70240c4bd7521 Mon Sep 17 00:00:00 2001
From: GHC GitLab CI <ghc-ci@gitlab-haskell.org>
Date: Mon, 7 Dec 2020 21:48:32 +0000
Subject: [PATCH] nonmoving: Assert deadlock-gc promotion invariant

When performing a deadlock-detection GC we must ensure that all objects
end up in the non-moving generation. Assert this in scavenge.
---
 rts/sm/Scav.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c
index 941e3b399fb7..3892b04ca04a 100644
--- a/rts/sm/Scav.c
+++ b/rts/sm/Scav.c
@@ -440,6 +440,14 @@ scavenge_block (bdescr *bd)
 
   p = bd->u.scan;
 
+  // Sanity check: See Note [Deadlock detection under nonmoving collector].
+#if defined(DEBUG)
+  if (RtsFlags.GcFlags.useNonmoving && deadlock_detect_gc) {
+      ASSERT(bd->gen == oldest_gen);
+  }
+#endif
+
+
   // we might be evacuating into the very object that we're
   // scavenging, so we have to check the real bd->free pointer each
   // time around the loop.
-- 
GitLab