From 3a7e4d98248a28b2b7418e136759089f887bd195 Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 1 Oct 2001 10:52:36 +0000 Subject: [PATCH] [project @ 2001-10-01 10:52:36 by simonmar] Fix a bug in the heap size calculation, where a negative result wasn't noticed because we're working with unsigned types. We now explicitly test that the heap has enough room for the minimum allocation area size, otherwise a heap overflow is reported. --- ghc/rts/GC.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ghc/rts/GC.c b/ghc/rts/GC.c index d978fce..713c579 100644 --- a/ghc/rts/GC.c +++ b/ghc/rts/GC.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: GC.c,v 1.122 2001/08/30 10:22:52 simonmar Exp $ + * $Id: GC.c,v 1.123 2001/10/01 10:52:36 simonmar Exp $ * * (c) The GHC Team 1998-1999 * @@ -758,6 +758,14 @@ GarbageCollect ( void (*get_roots)(evac_fn), rtsBool force_major_gc ) // different if compaction is turned on, because we don't need // to double the space required to collect the old generation. if (max != 0) { + + // this test is necessary to ensure that the calculations + // below don't have any negative results - we're working + // with unsigned values here. + if (max < min_alloc) { + heapOverflow(); + } + if (oldest_gen->steps[0].is_compacted) { if ( (size + (size - 1) * (gens - 2) * 2) + min_alloc > max ) { size = (max - min_alloc) / ((gens - 1) * 2 - 1); -- 1.7.10.4