in reply to Re: Object reference disappearing during global destruction
in thread Object reference disappearing during global destruction

I had the exact same issue but in a mod_perl enviro. After a few days I found the following in our memoization routines to be the problem:
return join '', map { $_->{type} eq 'static' ? $_->{body} : $self->execute($_) } @{$self->{BODY}};
changing it to the following fixes the havoc:
my @bodies = @{$self->{BODY}}; return join '', map { $_->{type} eq 'static' ? $_->{body} : $self->execute($_) } @bodies;

dereferencing and iterating over the deref'ed data with maps do untowardly things to item refcounts and the gc reaps its victims when it pleases.

execute is just a nice wrapper for an eval. it touches nothing inappropriately.

hope this helps a fellow weary soul.