rts/GC: Add an obvious assertion during block initialization
authorÖmer Sinan Ağacan <omer@well-typed.com>
Tue, 5 Feb 2019 15:40:29 +0000 (10:40 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 18 Jun 2019 22:08:33 +0000 (18:08 -0400)
Namely ensure that block descriptors are initialized with valid
generation numbers.

includes/rts/storage/GC.h

index 1571975..81850f1 100644 (file)
@@ -240,9 +240,14 @@ void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p);
 /* (needed when dynamic libraries are used). */
 extern bool keepCAFs;
 
+#include "rts/Flags.h"
+
 INLINE_HEADER void initBdescr(bdescr *bd, generation *gen, generation *dest)
 {
     bd->gen     = gen;
     bd->gen_no  = gen->no;
     bd->dest_no = dest->no;
+
+    ASSERT(gen->no < RtsFlags.GcFlags.generations);
+    ASSERT(dest->no < RtsFlags.GcFlags.generations);
 }