on master help sign in
Fix GC heap sizing

If there's still not enough room after a GC, grow the heap and do it again so that there is enough room. (This is a quick hack to fix a rare issue with large buffers!)

commitac930f3dcd8ff9c96872ff1d61473c44cd13784a authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSat 28 Sep 2019, 20:30 (7 years ago) parent7af67ac
1 file changed+7
rts/idris_rts.c+7
rts/idris_rts.c+7
@@ -242,6 +242,13 @@ void* iallocate(VM * vm, size_t isize, int outerlock) {
242242 vm->heap.size += size;
243243 }
244244 idris_gc(vm);
245+
246+ // If there's still not enough room, grow the heap and try again
247+ if (vm->heap.next + size >= vm->heap.end) {
248+ vm->heap.size += size+vm->heap.growth;
249+ idris_gc(vm);
250+ }
251+
245252#ifdef HAS_PTHREAD
246253 if (lock) { // not message passing
247254 pthread_mutex_unlock(&vm->alloc_lock);