From adb25ff96f9ab29a009b5d1e2f3baf82a1308a76 Mon Sep 17 00:00:00 2001 From: Costa Vitor Date: Tue, 2 Jun 2009 18:08:18 -0500 Subject: [PATCH] growglobal would core dump over holes. --- C/grow.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/C/grow.c b/C/grow.c index 1933d3a19..846f03f81 100644 --- a/C/grow.c +++ b/C/grow.c @@ -813,10 +813,17 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit) YAPEnterCriticalSection(); /* we always shift the local and the stack by the same amount */ if (do_grow) { - /* This is what happens to the base of the stack */ - BaseDiff = Yap_GlobalBase-old_GlobalBase; - /* if we grow, we need to move the stacks */ - LDiff = TrDiff = size+BaseDiff; + /* we got over a hole */ + if (minimal_request) { + /* we went over a hole */ + BaseDiff = size+((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)-minimal_request; + LDiff = TrDiff = size; + } else { + /* we may still have an overflow */ + BaseDiff = Yap_GlobalBase != old_GlobalBase; + /* if we grow, we need to move the stacks */ + LDiff = TrDiff = BaseDiff+size; + } } else { /* stay still */ LDiff = TrDiff = 0;