I posted a problem I was having with the destruct sequence about a
month ago. I subsequently was swamped and, since it was at the end of
the program, I let it go. I also found some problems with another
module's error handling that I thought was really causing the problem.
With that access fixed, I still get errors.

I have had some breathing room, so I'd like to see if I can provide
enough info this time around. I tried to recreate with a small test,
but I've had trouble. I'd like to see what folks think with the larger
set of code.

Some info up front:

$ pmvers Moose
0.72

$ pmvers Class::MOP
0.78

Perl is 5.10.0

My issue can be seen from the following at the end of my log file:

00: No messages on queue. Bye!
01: In LTH::Mqueue::DEMOLISH() (LTH::Mqueue=HASH(0x1c4d0d8))
02: In LTH::DEMOLISH() (LTH::Mqueue=HASH(0x1c4d0d8))
03: In LTH::Config::DEMOLISH() (LTH::Config=HASH(0x18eea0))
       (in cleanup) Can't call method "execute" on an undefined value
at /opt/perl.v5.10.0/lib/site_perl/5.10.0/Moose/Object.pm line 55
during global destruction.
04: In LTH::Message::ETN::DEMOLISH() (LTH::Message::ETN=HASH(0x1bd3250))
05: In LTH::Message::DEMOLISH() (LTH::Message::ETN=HASH(0x1bd3250))
       (in cleanup) Can't call method "execute" on an undefined value
at /opt/perl.v5.10.0/lib/site_perl/5.10.0/Moose/Object.pm line 55
during global destruction.

00) The application, having no work to do, does and exit(0)

01) It is decided that the first object to destroy is the LTH::Mqueue
object (line 01, 0x1c4d0d8). Why? I do not know.

02) In doing so, it destroys its PARENT LTH (line 02, same object,
0x1c4d0d8), including the metadata?

03) Next to be destroyed is the LTH::Config object at line 03 and this
has a problem. This is probably because the destruct of LTH at line 2
blew away the parent LTH meta data?

04) LTH::Message::ETN is destroyed at line 04

05) LTH::Message is next to be destroyed, but cannot, again  because
the destruct of LTH at line 2 probably blew away the parent LTH meta
data?

Do I have the diagnosis right? Here are the relevent parts of the
modules. Now, I know that I really don't need these DEMOLISH subs, but
even so, they should work, right? I would think that the destruct
sequence would be

LTH::Message::ETN

then, in any order
LTH::Message
LTH::Mqueue
LTH::Config

and finally
LTH

Is this a bad assumption?

Relevent portions of modules
##LTH
...
sub DEMOLISH {
   my $self = shift;
   LogEcho ("In LTH::DEMOLISH() ($self)");
}

##LTH::Mqueue
extends 'LTH';
...
sub DEMOLISH {
   my $self = shift;
   LogEcho ("In LTH::Mqueue::DEMOLISH() ($self)");
}

##LTH::Config
extends 'LTH';
...
sub DEMOLISH {
   my $self = shift;
   LogEcho ("In LTH::Config::DEMOLISH() ($self)");
}

##LTH::Message
extends 'LTH';
...
sub DEMOLISH {
   my $self = shift;
   LogEcho ("In LTH::Message::DEMOLISH() ($self)");
   if ($self->save_conn_is_open()) {
       for (values(%{$self->save_conn()->{CachedKids}})) {
           $_->finish();
       }
       $self->save_conn()->disconnect();
   }
}

##LTH::Message::ETN
extends 'LTH::Message';
...
sub DEMOLISH {
   my $self = shift;
   LogEcho ("In LTH::Message::ETN::DEMOLISH() ($self)");
}


-- 
Matthew O. Persico

Reply via email to