]> granicus.if.org Git - gc/commitdiff
Fix mark stack overflow checking in push_selected
authorIvan Maidanski <ivmai@mail.ru>
Fri, 22 Jun 2018 22:17:46 +0000 (01:17 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 18 Jul 2018 21:02:37 +0000 (00:02 +0300)
(a cherry-pick of commit 84053cd2 from 'release-7_4')

* mark.c (GC_push_selected): In case of a danger of mark stack overflow
after the first GC_push_all() call then call GC_push_all(bottom, top)
and return; remove redundant checking of GC_mark_stack_top at the end
of the function (overflow is already checked in GC_push_all).

mark.c

diff --git a/mark.c b/mark.c
index 5a7ec736717515d2bfcb95955a01cdecec6b67d8..969a02b37bce1422d95645dc6dbe77a31b0a46a6 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1329,6 +1329,11 @@ void GC_push_all(ptr_t bottom, ptr_t top)
         return;
     }
     if ((*dirty_fn)(h-1)) {
+        if ((word)(GC_mark_stack_top - GC_mark_stack)
+            > 3 * GC_mark_stack_size / 4) {
+            GC_push_all(bottom, top);
+            return;
+        }
         GC_push_all(bottom, (ptr_t)h);
     }
 
@@ -1349,9 +1354,6 @@ void GC_push_all(ptr_t bottom, ptr_t top)
     if ((ptr_t)h != top && (*dirty_fn)(h)) {
        GC_push_all((ptr_t)h, top);
     }
-    if (GC_mark_stack_top >= GC_mark_stack_limit) {
-        ABORT("Unexpected mark stack overflow");
-    }
   }
 
   void GC_push_conditional(ptr_t bottom, ptr_t top, GC_bool all)