develooper Front page | perl.perl5.porters | Postings from November 2003

Re: problems with Scalar::Util::weaken() and CLONE

Thread Previous
Elizabeth Mattijsen
November 14, 2003 16:02
Re: problems with Scalar::Util::weaken() and CLONE
Message ID:
Not sure whether this is the same or something even more problematic:

use threads;
use Scalar::Util qw(weaken);
my $object = Foo->new;

my $ref = $object;
weaken( $ref );

threads->new( sub { $ref = $object } )->join; # the $ref = $object 
causes problems
warn "thread ended\n";

package Foo;
sub new { bless {},shift }
sub DESTROY { warn "DESTROY called in ".(threads->tid)." with $_[0]\n" }


DESTROY called in 0 with Foo=HASH(0x198d74)
panic: magic_killbackrefs at line 9.
DESTROY called in 1 with Foo=HASH(0x1f8cb4)
Attempt to free unreferenced scalar: SV 0x1f8cc0 during global destruction.
DESTROY called in 0 with Foo=HASH(0xfc364)
Scalars leaked: 3

I wonder where that first DESTROY is coming from.  And also note that 
the final "warn" (thread ended) is not reached.


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