From dc8f6d703a97bbde751b81df4b2c81a8b8ca2f05 Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 5 Sep 2006 23:10:42 +0000 Subject: [PATCH] Handle code heap exhaustion with a critical error, instead of sig11 + corrupt image --- TODO.FACTOR.txt | 1 - vm/compiler.c | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 10418257aa..84793b3f91 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -11,7 +11,6 @@ ] - prettier printing of hashtable literals, alists, cond, ... - alien-indirect -- handle code heap exhaustion with a critical error - more compact relocation info - problem if major gc happens during relocation - in fact relocation should not cons at all diff --git a/vm/compiler.c b/vm/compiler.c index df0317eb45..bdd1490eba 100644 --- a/vm/compiler.c +++ b/vm/compiler.c @@ -225,6 +225,12 @@ CELL add_compiled_block(CELL code_format, F_VECTOR *code, CELL literal_length = untag_fixnum_fast(literals->top) * CELLS; CELL words_length = untag_fixnum_fast(words->top) * CELLS; + CELL total_length = sizeof(F_COMPILED) + code_length + rel_length + + literal_length + words_length; + + if(compiling.here + total_length >= compiling.limit) + critical_error("Code heap exhausted",compiling.limit); + /* compiled header */ F_COMPILED header; header.code_length = code_length;