>From 4be43f6d19445226acb467a70eac6b1a036e947f Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Thu, 17 Oct 2013 21:23:18 +0200 Subject: [PATCH] Don't do a shady unsigned comparison, but ensure we're growing the heap before checking it grows enough to fit the stack --- runtime.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/runtime.c b/runtime.c index 0ed18de..4189476 100644 --- a/runtime.c +++ b/runtime.c @@ -3296,12 +3296,13 @@ C_regparm void C_fcall C_rereclaim2(C_uword size, int double_plus) if(size < MINIMAL_HEAP_SIZE) size = MINIMAL_HEAP_SIZE; /* - * Heap must at least grow enough to accommodate first generation - * (nursery). Because we're calculating the total heap size here - * (fromspace *AND* tospace), we have to double the stack size, - * otherwise we'd accommodate only half the stack in the tospace. + * When heap grows, ensure it's enough to accommodate first + * generation (nursery). Because we're calculating the total heap + * size here (fromspace *AND* tospace), we have to double the stack + * size, otherwise we'd accommodate only half the stack in the tospace. */ - if(size - heap_size < stack_size * 2) size = heap_size + stack_size * 2; + if(size > heap_size && size - heap_size < stack_size * 2) + size = heap_size + stack_size * 2; if(size > C_maximal_heap_size) size = C_maximal_heap_size; -- 1.8.3.4