I am not sure this is a bug, but it seems to me like DESTROY isn't
always called the same number of times when Devel::Leak::Object
(GLOBAL_bless) is activated compared to when it isn't. I'm not sure that
it ought to, but I think so?
I have created a little test-program (attached) that shows this. When I
run it, I get this output when D:L:O is commented out:
car Car=HASH(0x6ecdd0)
* DESTROY Car=HASH(0x6ecdd0)
producer Producer=HASH(0x6ecdd0)
car Car=HASH(0x6ece20)
* DESTROY Car=HASH(0x6ece20)
* DESTROY Producer=HASH(0x6ecdd0)
car Car=HASH(0x6ece30)
* DESTROY Car=HASH(0x6ece30)
which makes sense to me, I create a car and it is DESTROYed as it goes
out of scope, then a producer and a car, also DESTROYed, and finally
another car; DESTROYed.
If I comment in Devel::Leak::Object qw{ GLOBAL_bless }, I get this output:
Devel::Leak::Object version: 0.92
car Car=HASH(0x736610)
* DESTROY Car=HASH(0x736610)
producer Producer=HASH(0x736610)
car Car=HASH(0x7461c0)
* DESTROY Producer=HASH(0x736610)
car Car=HASH(0x746140)
Tracked objects by class:
Now, after I have created a producer, no cars are DESTROYed anymore!
I think it has to do with how Devel::Leak::Object::DESTROY_NEXT is
populated and interpreted, because if I add a warn line like this:
--- Object.pm.orig 2008-10-08 11:36:59.000000000 +0200
+++ Object.pm 2008-10-08 16:35:14.000000000 +0200
@@ -119,6 +119,7 @@
}
my \$super =
\$Devel::Leak::Object::DESTROY_NEXT{\$original}->{'$class'};
unless ( defined \$super ) {
+ warn "Failed to find super-method for class \$class in package
$class";
die "Failed to find super-method for class \$class in package
$class";
}
if ( \$super ) {
I get this output:
Devel::Leak::Object version: 0.92
car Car=HASH(0x736590)
* DESTROY Car=HASH(0x736590)
producer Producer=HASH(0x736590)
car Car=HASH(0x745980)
Failed to find super-method for class Car in package Producer at (eval
5) line 46.
* DESTROY Producer=HASH(0x736590)
car Car=HASH(0x745900)
Failed to find super-method for class Car in package Producer at (eval
5) line 46.
Tracked objects by class:
I haven't really understood how the DESTROY_NEXT structure is supposed
to work, so I may very well be mistaken.
If this is a bug, I will be happy to rework my program into the tests (I
must admit I haven't looked at them yet.)
Best regards, (an(other)) Adam