>From 110c57bb73939e6c5fd18ebb0aee2b9fff7a16ba Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Fri, 26 Jul 2013 21:48:08 +0200 Subject: [PATCH] Panic when maximum heap size exhausted, instead of crashing hard (fixes #892). It used to simply return from C_rereclaim2 and carry on as if the heap was resized(!) --- NEWS | 1 + runtime.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 0f77a4c..2d9ab2b 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,7 @@ - Special events in poll() are now handled, avoiding hangs in threaded apps. - When invoking procedures with many rest arguments directly (not via APPLY), raise an error when argument count limit was reached instead of crashing. + - When the maximum allowed heap size is reached, panic instead of crashing. - C API - Deprecated C_get_argument[_2] and C_get_environment_variable[_2] functions. diff --git a/runtime.c b/runtime.c index bbeb2f6..85a1b1f 100644 --- a/runtime.c +++ b/runtime.c @@ -3305,8 +3305,6 @@ C_regparm void C_fcall C_rereclaim2(C_uword size, int double_plus) if(size > C_maximal_heap_size) size = C_maximal_heap_size; - if(size == heap_size) return; - if(debug_mode) C_dbg(C_text("debug"), C_text("resizing heap dynamically from " UWORD_COUNT_FORMAT_STRING "k to " UWORD_COUNT_FORMAT_STRING "k ...\n"), heap_size / 1024, size / 1024); @@ -3417,7 +3415,7 @@ C_regparm void C_fcall C_rereclaim2(C_uword size, int double_plus) heap_free (heapspace2, heapspace2_size); if ((heapspace2 = heap_alloc (size, &tospace_start)) == NULL) - panic(C_text("out ot memory - cannot allocate heap segment")); + panic(C_text("out of memory - cannot allocate next heap segment")); heapspace2_size = size; heapspace1 = new_heapspace; -- 1.8.2.3