chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Another subtle GC problem


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Another subtle GC problem
Date: Thu, 17 Oct 2013 21:33:37 +0200
User-agent: Mutt/1.4.2.3i

Hi all,

I decided to take another look at the GC in an attempt to
understand it better, and found yet another iffy line of code:

When comparing the heap growth to the current heap size plus
the stack size, two unsigned quantities are subtracted from
eachother (size is a C_uword parameter to C_rereclaim2,
heap_size is a size_t, which is also unsigned), and then
compared to be less than stack_size * 2.

If the heap is not growing, but shrinking, this unsigned
subtraction will underflow and cause it to result in a
huge value.  This happens to work, but I think the attached
patch makes it more explicit what's really happening: it
only does the subtraction and comparison when the new size
is bigger than the old heap size (so we're growing the heap,
due to memory pressure).

When shrinking the heap, this check won't need to be run because
we've just done a GC, so there *should be* no pressure on
the nursery, so it won't get copied to the heap.  But I don't
fully grok this part yet, so don't take my word for it.

Cheers,
Peter
-- 
http://www.more-magic.net

Attachment: 0001-Don-t-do-a-shady-unsigned-comparison-but-ensure-we-r.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]