Fix assertion in GC_steal_mark_stack for non-heap regions
authorIvan Maidanski <ivmai@mail.ru>
Sat, 10 Dec 2016 07:14:39 +0000 (10:14 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 10 Dec 2016 07:15:56 +0000 (10:15 +0300)
(similar to commit da2fcda)

* mark.c (GC_steal_mark_stack): Replace top->mse_descr.w with descr
in assertion; relax assertion condition for descr (length-containing
mse_descr.w could be larger than the current GC heap size if
mse_start points to a region in a stack or a program data root;
e.g. it could happen if MemorySanitizer is used).

mark.c

diff --git a/mark.c b/mark.c
index 167fa5a..e6b212e 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -968,9 +968,13 @@ STATIC mse * GC_steal_mark_stack(mse * low, mse * high, mse * local,
             ++top;
             top -> mse_descr.w = descr;
             top -> mse_start = p -> mse_start;
-            GC_ASSERT((top->mse_descr.w & GC_DS_TAGS) != GC_DS_LENGTH ||
-                      top->mse_descr.w < (word)GC_greatest_plausible_heap_addr
-                                         - (word)GC_least_plausible_heap_addr);
+            GC_ASSERT((descr & GC_DS_TAGS) != GC_DS_LENGTH
+                      || descr < (word)GC_greatest_plausible_heap_addr
+                                        - (word)GC_least_plausible_heap_addr
+                      || (word)(p->mse_start + descr)
+                            <= (word)GC_least_plausible_heap_addr
+                      || (word)p->mse_start
+                            >= (word)GC_greatest_plausible_heap_addr);
             /* If this is a big object, count it as                     */
             /* size/256 + 1 objects.                                    */
             ++i;