diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c
index 941e3b399fb7bafbee812d625bf1222d446e65c4..3892b04ca04a404f333b7d2df755734bbbe5eb28 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.