diff --git a/src/opt/mm_buddyTemplate.c b/src/opt/mm_buddyTemplate.c index 4544d9f8..2af2f1e4 100644 --- a/src/opt/mm_buddyTemplate.c +++ b/src/opt/mm_buddyTemplate.c @@ -36,7 +36,10 @@ FORCE_INLINE void BN(splitTo)(EmptyValue* c, i64 from, i64 to, bool notEqual) { static NOINLINE void* BN(allocateMore)(i64 bucket, u8 type, i64 from, i64 to) { u64 sz = BSZ(from); - if (mm_heapAlloc+sz >= mm_heapMax) { printf("Heap size limit reached\n"); exit(1); } + if (mm_heapAlloc+sz >= mm_heapMax) { + if (sz>100000) thrM("Heap size limit reached"); // if allocating a large thing, it should be possible to recover + printf("Heap size limit reached\n"); abort(); + } mm_heapAlloc+= sz; // gc_maybeGC(); EmptyValue* c = MMAP(sz); diff --git a/src/vm.c b/src/vm.c index b1c4f4ce..7c654bec 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1193,7 +1193,8 @@ NOINLINE void printErrMsg(B msg) { NOINLINE NORETURN void thr(B msg) { // printf("gStack %p-%p:\n", gStackStart, gStack); B* c = gStack; // while (c>gStackStart) { print(*--c); putchar('\n'); } printf("gStack printed\n"); - if (cf>cfStart) { + + if (cf>cfStart) { // something wants to catch errors catchMessage = msg; cf--; @@ -1207,17 +1208,18 @@ NOINLINE NORETURN void thr(B msg) { if (cfStart+cf->cfDepth > cf) err("bad catch cfDepth"); cf = cfStart+cf->cfDepth; longjmp(cf->jmp, 1); + } else { // uncaught error + assert(cf==cfStart); + printf("Error: "); printErrMsg(msg); putchar('\n'); fflush(stdout); + Env* envEnd = envCurr+1; + unwindEnv(envStart-1); + vm_pst(envCurr+1, envEnd); + #ifdef DEBUG + __builtin_trap(); + #else + exit(1); + #endif } - assert(cf==cfStart); - printf("Error: "); printErrMsg(msg); putchar('\n'); fflush(stdout); - Env* envEnd = envCurr+1; - unwindEnv(envStart-1); - vm_pst(envCurr+1, envEnd); - #ifdef DEBUG - __builtin_trap(); - #else - exit(1); - #endif } NOINLINE NORETURN void thrM(char* s) {