[Gc] behaviour of GC_local_malloc(0)

Boehm, Hans hans.boehm at hp.com
Tue Apr 25 10:20:07 PDT 2006


Just to close off this thread:

I checked a more elaborate patch into 7.0alpha.

It sounds like for 6.7, the best answer is to either no allocate zero
size objects with GC_local_malloc, or to not explicitly deallocate them.

Hans

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com 
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Peter Wang
> Sent: Thursday, April 20, 2006 7:24 AM
> To: gc at napali.hpl.hp.com
> Subject: Re: [Gc] behaviour of GC_local_malloc(0)
> 
> On 2006-04-19, Hans Boehm <Hans.Boehm at hp.com> wrote:
> > You're right.  This is a bug.  A size zero GC_local_malloc 
> allocation 
> > currently just returns a fixed address outside the real heap.  The 
> > only pleasant property this has is that it can be 
> implemented without 
> > an explicit zero check in the allocator.
> > 
> > The trivial (untested) workaround consists of enabling the hdr == 0 
> > test in GC_free unconditionally, not just for malloc redirection.  
> > That way explicit deallocations of objects outside the real 
> heap will 
> > be implicitly ignored.
> 
> Thanks, I've tried that now.  It did reduce the number of 
> crashes in the test cases of the Mercury compiler (what I'm 
> working on), but some were still present.  Maybe I did 
> something wrong though.
> 
> (Actually, for our case, zero-size allocations seems to be an 
> accident rather than necessary by design, so just returning 
> NULL was enough.)
> 
> Peter
> 
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> 



More information about the Gc mailing list