From 4685f4de7b4cbbd71dbfa1867635e1e0e790a6d1 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 23 Jun 2018 01:17:46 +0300 Subject: [PATCH] Fix mark stack overflow checking in push_selected * 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mark.c b/mark.c index b9f43dd0..d5fae4e6 100644 --- a/mark.c +++ b/mark.c @@ -1383,6 +1383,11 @@ GC_API void GC_CALL GC_push_all(void *bottom, void *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, h); } @@ -1403,9 +1408,6 @@ GC_API void GC_CALL GC_push_all(void *bottom, void *top) if ((ptr_t)h != top && (*dirty_fn)(h)) { GC_push_all(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(void *bottom, void *top, int all) -- 2.50.1