growglobal would core dump over holes.

This commit is contained in:
Costa Vitor 2009-06-02 18:08:18 -05:00
parent f10dde5b90
commit adb25ff96f
1 changed files with 11 additions and 4 deletions

View File

@ -813,10 +813,17 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
YAPEnterCriticalSection(); YAPEnterCriticalSection();
/* we always shift the local and the stack by the same amount */ /* we always shift the local and the stack by the same amount */
if (do_grow) { if (do_grow) {
/* This is what happens to the base of the stack */ /* we got over a hole */
BaseDiff = Yap_GlobalBase-old_GlobalBase; if (minimal_request) {
/* if we grow, we need to move the stacks */ /* we went over a hole */
LDiff = TrDiff = size+BaseDiff; 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 { } else {
/* stay still */ /* stay still */
LDiff = TrDiff = 0; LDiff = TrDiff = 0;