[Gc] Crash in GC_realloc - HDR(h) NULL

Emmeran Seehuber rototor at rototor.de
Mon Aug 25 01:38:18 PDT 2008


Am Freitag, 22. August 2008 schrieb Boehm, Hans:
> > -----Original Message-----
> > From: gc-bounces at napali.hpl.hp.com
> > [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Emmeran Seehuber
> > Sent: Friday, August 22, 2008 4:33 AM
> > To: gc at napali.hpl.hp.com
> > Subject: [Gc] Crash in GC_realloc - HDR(h) NULL
> > hddr is NULL here. In which cases can HDR(h) return NULL?
>
> That should mean that h is not in the garbage-collected heap.
Ah thanks.

>
> My first suspicion would be that the object being reallocated is in fact
> not allocated with GC_MALLOC, but through some other means.  It would be
> good to check at the allocation site that this is in fact the pointer
> returned by the GC_MALLOC call, and that GC_find_header(returned pointer)
> gives you a non-null pointer to the block header at that point.

The offending class is a custom dynamic array implementation, which allows to 
allocate memory in different ways:

template<class T, bool containsPointer = true, bool collectable = true, bool 
useOnlySysMem = false>
class ArrayImpl

This class seems to work correctly in all cases .... -> I've now added some 
asserts to it, so that it expects a GC header when allocating, freeing and 
reallocating GC memory and expects hdr == NULL in all other cases. I`ll see 
if this asserts trigger.

>
> If that's OK, there's a more remote chance that the block containing the
> object has been entirely reclaimed, because the pointer was hidden from the
> collector, or the object was previously explcitly deallocated.  But in that
> case, I'd be surprised that you're only seeing this particular failure. 
> How large is the object that's involved here?

One time it crashed the array contained 200 pointers -> So the block given to 
GC_realloc had a size of 800 bytes. The other time it contained 800 pointers, 
so the size was 3200 bytes.

Thanks,

Emmeran Seehuber
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://napali.hpl.hp.com/pipermail/gc/attachments/20080825/b676210d/attachment.pgp


More information about the Gc mailing list