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

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

Thread Previous
From:
Elizabeth Mattijsen
Date:
November 14, 2003 16:02
Subject:
Re: problems with Scalar::Util::weaken() and CLONE
Message ID:
p05111b0abbdb1cdd8e2d@[192.168.56.3]
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" }

gives:


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.


Liz

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About