[Gc] double frees

Boehm, Hans hans.boehm at hp.com
Mon Nov 15 11:03:26 PST 2004


Probably most code written for the garbage collector never calls GC_FREE, so
that's actually quite a strong guarantee.  

If you define GC_DEBUG, you get some extra checking, and duplicate
deallocations will probably be reported.

The goal here is not to prevent you from doing bad things in C or C++;
if you are programming in those languages you currently have many other
ways to do that. The goal is to allow you to write less error-prone code.

If you are programming in C# with Mono or in Java with gcj, and using
the collector that way, then there is no way to call GC_FREE.

Hans

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com
> [mailto:gc-bounces at napali.hpl.hp.com]On Behalf Of Hans Van den Eynden
> Sent: Monday, November 15, 2004 10:26 AM
> To: MenTaLguY; gc at napali.hpl.hp.com
> Subject: Re: [Gc] double frees
> 
> 
> It gives you the freedom to write code that never calls GC_FREE() or
> delete.
> 
> That's it?? So there is no extra control to see that an 
> object is already deleted?
> What will happen when I double delete an object?
> 
> 
> 
> MenTaLguY wrote:
> 
> >On Sun, 14 Nov 2004, Hans Van den Eynden wrote:
> >
> >  
> >
> >>On Wed, 10 Nov 2004, MenTaLguY wrote:
> >>
> >>    
> >>
> >>>If your code does avoid freeing objects explicitly, and 
> your application
> >>>or compiler cannot be tricked into hiding information from 
> the collector,
> >>>then you are at least safe from double frees or 
> dereferencing dangling
> >>>pointers."
> >>>      
> >>>
> >>How does the GC prevent against double frees from GC_FREE() and
> >>delete??? Are there some bytes set??
> >>    
> >>
> >
> >It gives you the freedom to write code that never calls GC_FREE() or
> >delete.
> >
> >-mental
> >
> >  
> >
> 
> _______________________________________________
> 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