From: Radu Greab Date: Sat, 8 Jun 2002 16:59:56 +0000 (+0300) Subject: Re: [ID 20020601.005] Storable: STORABLE_freeze mechanism leaks memory (unfreed SVs) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e2505e060ba20929063cce88fa63b09f61f25af;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20020601.005] Storable: STORABLE_freeze mechanism leaks memory (unfreed SVs) Message-ID: <15618.3548.55951.66902@ix.netsoft.ro> A test for #17082. p4raw-id: //depot/perl@17089 --- diff --git a/ext/Storable/t/recurse.t b/ext/Storable/t/recurse.t index d2da630..18b461b 100644 --- a/ext/Storable/t/recurse.t +++ b/ext/Storable/t/recurse.t @@ -25,7 +25,7 @@ sub ok; use Storable qw(freeze thaw dclone); -print "1..32\n"; +print "1..33\n"; package OBJ_REAL; @@ -278,9 +278,43 @@ sub make { sub set_c2 { $_[0]->{c2} = $_[1] } +# +# Is the reference count of the extra references returned from a +# STORABLE_freeze hook correct? [ID 20020601.005] +# +package Foo2; + +sub new { + my $self = bless {}, $_[0]; + $self->{freezed} = "$self"; + return $self; +} + +sub DESTROY { + my $self = shift; + $::refcount_ok = 1 unless "$self" eq $self->{freezed}; +} + +package Foo3; + +sub new { + bless {}, $_[0]; +} + +sub STORABLE_freeze { + my $obj = shift; + return ("", $obj, Foo2->new); +} + +sub STORABLE_thaw { } # Not really used + package main; +use vars qw($refcount_ok); my $o = CLASS_OTHER->make(); my $c2 = CLASS_2->make($o); my $so = thaw freeze $o; +$refcount_ok = 0; +thaw freeze(Foo3->new); +ok 33, $refcount_ok == 1;