]> 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>
Sun, 8 Jul 2018 21:06:25 +0000 (00:06 +0300)
(a cherry-pick of commit 4685f4de from 'master')

* 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 26ac9f598492decb206d765efc331629f3e1ff35..d2ae46cf055a380aaa439be9f437169d0b93b7c2 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1370,6 +1370,11 @@ GC_API void GC_CALL GC_push_all(char *bottom, char *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);
     }
 
@@ -1390,9 +1395,6 @@ GC_API void GC_CALL GC_push_all(char *bottom, char *top)
     if ((ptr_t)h != top && (*dirty_fn)(h)) {
        GC_push_all((ptr_t)h, top);
     }
-    if ((word)GC_mark_stack_top >= (word)GC_mark_stack_limit) {
-        ABORT("Unexpected mark stack overflow");
-    }
   }
 
   GC_API void GC_CALL GC_push_conditional(char *bottom, char *top, int all)