[Gc] Defeating finalization

Ludovic Courtès ludovic.courtes at laas.fr
Thu Apr 20 06:28:04 PDT 2006


Hi,

I'm looking for a way to implement guardians [0] on top of `libgc'.  One
solution I thought of is the following:

  1. Register a finalization function for each guarded object;

  2. Whenever that function is called, have it store a pointer to the
     object being finalized in a list of ``zombie'' objects that the
     guardian can eventually return to user code.  Roughly, the
     finalization procedure would look like the following:

       static void
       my_fake_finalizer (GC_PTR obj, GC_PTR client_data)
       {
         enqueue (&zombie_list, obj);
       }


The obvious question is: Is this permitted?  IOW, what happens if a
finalizer creates new references to an object being finalized?

Thanks,
Ludovic.


[0] R. Kent Dybvig et al., "Guardians in a Generation-Based Garbage
    Collector", ACM SIGPLAN Conference on Programming Language Design
    and Implementation, June 1993,
    http://www.cs.indiana.edu/~dyb/papers/guardians-pldi93.ps.gz .



More information about the Gc mailing list