~ chicken-core (chicken-5) 8bb3b4c73399cbf79311d7222b7ba2668861e32c
commit 8bb3b4c73399cbf79311d7222b7ba2668861e32c
Author: Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Fri Jul 26 21:48:08 2013 +0200
Commit: Moritz Heidkamp <moritz@twoticketsplease.de>
CommitDate: Sun Jul 28 20:02:51 2013 +0200
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(!)
Signed-off-by: Moritz Heidkamp <moritz@twoticketsplease.de>
diff --git a/NEWS b/NEWS
index 0f77a4c0..2d9ab2bc 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 bbeb2f62..85a1b1f8 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;
Trap