]> git.llucax.com Git - software/dgc/cdgc.git/commitdiff
Check the sentinel invariant in release builds too
authorLeandro Lucarella <llucax@gmail.com>
Thu, 26 Aug 2010 21:53:19 +0000 (18:53 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Thu, 26 Aug 2010 21:53:19 +0000 (18:53 -0300)
When building a release, the sentinel invariant isn't checked, even if the
"sentinel" option is used. This patches checks the invariant always when
the option is activated, abort()ing the program if the invariant fails.

rt/gc/cdgc/gc.d

index 78f673c4335c59811026b20378c41f83e64e4a3f..1afe5a0a4850d78487c4fec272e746f7fbe53b3c 100644 (file)
@@ -2093,8 +2093,9 @@ void sentinel_init(void *p, size_t size)
 
 void sentinel_Invariant(void *p)
 {
-    assert(*sentinel_pre(p) == SENTINEL_PRE);
-    assert(*sentinel_post(p) == SENTINEL_POST);
+    if (*sentinel_pre(p) != SENTINEL_PRE ||
+            *sentinel_post(p) != SENTINEL_POST)
+        cstdlib.abort();
 }