Subject: | looking for super method of the same package in DESTROY for non tracked object |
I believe there is a bug related to the following logic in overridden DESTROY method:
...
\$original = \$class;
}
...
my \$super = \$Devel::Leak::Object::DESTROY_NEXT{\$original}->{'$class'};
unless ( defined \$super ) {
die "Failed to find super-method for class \$class in package $class";
}
imagine an object which hasn't been tracked, but another object(s) of the same class (which
do have the original DESTROY) have been tracked - so the class got the overridden DESTROY.
So for non tracked object the call will be made on \$super =
\$Devel::Leak::Object::DESTROY_NEXT{\$original}->{'$class'};
which effectively searches for DESTROY_NEXT{$X}->{$X} - and failing later with
die "Failed to find super-method for class ...
see the following code to demonstrate that. Sorry it is a bit artificial, since here I have to use
the explicit DESTROY call. I wasn't able to use my real code where the explicit DESTROY is
not called - it would be too complex).
I also think the problem is specifically affecting the FileHandle objects, since they are
spawned sooner then bless is overridden.
#!/usr/bin/perl -w
use strict;
use Devel::Leak::Object qw(GLOBAL_bless);
use FileHandle;
$SIG{__DIE__} = sub { print "Report hidden die: ".$_[0]};
my $f = new FileHandle();
$f->DESTROY();