On Thu, 9 Oct 2003, Thomas Fjellstrom wrote:

> On October 9, 2003 09:57 am, Dan Sugalski wrote:
> > On Thu, 9 Oct 2003, Dave Mitchell wrote:
> > > On Thu, Oct 09, 2003 at 11:43:41AM -0400, Dan Sugalski wrote:
> > > > We've got ordered destruction on the big list 'o things to do, and it
> > > > looks like we need to get that done sooner rather than later. So, this
> > > > is a good chance for someone to burn those surplus SAN points and
> > > > become one with the great gibbering chaos at the center of the universe
> > > > (no, wait, that's not it) by digging into the DOD system.
> > > >
> > > > Not a huge task, we just need to order PMCs before destroying them, to
> > > > make sure we don't call the destructor for a PMC before we destroy the
> > > > things that depend on it. A quick run through the PMC pools to build up
> > > > a dependency chain if there's more than one PMC that needs destruction
> > > > should do it.
> > >
> > > I always thought that was a rather hard issue, due to circular
> > > dependencies. It's certainly the case that Perl5 is very poor at global
> > > destruction of objects.
> >
> > In the circular case you just pick a place and go from there -- there's no
> > good way to handle those. There are a lot of cases where there are
> > non-circular dependencies, though, so it seems worthwhile to take those in
> > order. Probably ought to be optional for all the sweeps except, perhaps,
> > the final one, though I expect perl, python, and ruby code will all enable
> > ordered destruction.
>
> I've been interested in how to clean up circular dependencies... Just how easy
> is it to find all cases? Is it possible? Like say a really really deep
> case... Should you just not care at that point, and say the programmer
> deserves what [s]he gets?

It's pretty easy to find the cases--if you pick an object with an active
destroy method, start tracing the tree, and hit that object during the
trace then you've got a circular structure. There's no reliable way of
properly cleaning these up, since any scheme you can think of (and people
have thought up a lot of 'em) can run leave you with a situation you can't
reasonably resolve.

The only good thing to do is clean up all the non-circular structures and
see if there's anything left (since sometimes destructors on other objects
can end up resolving the issue) and, if there is, picking an object at
random to start the destruction with. And for parrot, it *should* be
random, if we're not otherwise going to set a scheme in place. (Complete
with calls to rand() and everything)

                                        Dan

Reply via email to