On Wed, Sep 07, 2005 at 02:37:33PM +0200, Leopold Toetsch wrote: > Parrot calls the "destroy" vtable function for all PMCs that have marked > themselves with PObj_active_destroy_FLAG, when the object gets recycled > due to GC *or* at program exit.
If I have 2 objects in a self-referencing loop, what happens? A---+ ^ | | v +---B Clearly mark and sweep can spot these things before the end of the world, but how does all the destruction work? The GC has to call one PMC's destroy first, so let's call that one A. A's destroy gets called. At this time A is pointing to a valid B object, so it can make calls on B. At the end of this call, A is (presumably) in a consistent state, but not a state consistent with having other methods called on it. But is its vtable still active? Or is the vtable replaced with something else? Because what must come next is that B's destroy gets called. And as B still has a pointer to A, B might (naïvely) try to make calls on A. Or are all objects that actively destroy themselves also expected to actively swap their vtables to something safe? I'm not sure if this messy "call on a destructed object" scenario can occur for non-active-destroy objects. Nicholas Clark