develooper Front page | perl.perl5.porters | Postings from March 2017

Re: [perl #32714] Objects destroyed in the wrong order during globaldestruction

Thread Previous | Thread Next
Leon Timmermans
March 10, 2017 10:15
Re: [perl #32714] Objects destroyed in the wrong order during globaldestruction
Message ID:
On Thu, Mar 9, 2017 at 9:55 PM, Nick Wellnhofer via RT <> wrote:

> On Thu, 07 Jul 2016 09:49:52 -0700, wrote:
> > Based on the above suggestions to make a pragma and upload it to cpan,
> > and the report that Liz has done so, I believe this ticket can be
> > closed? I intend to close resolved in a week unless there is some
> > objection.
> I object to closing this bug. Perl really should run global destruction in
> two phases:
> 1. Decrease the refcount of globals like "our" variables which will run
> destructors in correct order unless there are circular references or
> refcount leaks.
> 2. Only then forcibly destroy the remaining objects.
> Ideally, it should be possible to tell which of the two phases is run.
> Some code may want to skip forced destruction in phase 2.
> There's no need for a pragma that adds additional overhead. Besides, "use
> ogd" doesn't seem to be very useful. In most cases you don't want LIFO
> order, but make sure that an object that is still referred to isn't
> destroyed before the referrer.

Destructors can and do depend on package variables, this would not solve
all non-circular cases. Just because the roots of the graph are package
variables doesn't mean all package variables are roots.

The proper solution would be to topologically sort the objects and then
destroy them in that order (ideally even taking into account that the
destruction can add new nodes to the graph), but this is non-trivial to
implement and to execute; and obviously would still not solve circular


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About