From: Father Chrysostomos (via RT) Date: Sun, 25 Jul 2010 19:46:06 +0000 (-0700) Subject: Hash assignment can zap weak references to the hash X-Git-Tag: accepted/trunk/20130322.191538~8271 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c480c903473b013658c29213ac3d1772ab6b63a;p=platform%2Fupstream%2Fperl.git Hash assignment can zap weak references to the hash [perl #76716] commits 044d8c24f and 64345bb broke backrefs to hashes that are merely cleared or undeffed, but not freed. Spotted by Father Chrysostomos. Test for it here (fixes coming next) --- diff --git a/t/op/hashassign.t b/t/op/hashassign.t index 3fa6c41..92ea5ca 100644 --- a/t/op/hashassign.t +++ b/t/op/hashassign.t @@ -8,7 +8,7 @@ BEGIN { # use strict; -plan tests => 215; +plan tests => 217; my @comma = ("key", "value"); @@ -306,3 +306,14 @@ foreach my $chr (60, 200, 600, 6000, 60000) { @expect{map "$_", @refs} = @types; ok (eq_hash(\%h, \%expect), 'blessed ref stringification'); } + +# [perl #76716] Hash assignment should not zap weak refs. +{ + my %tb; + use Scalar::Util; + Scalar::Util::weaken(my $p = \%tb); + %tb = (); + is $p, \%tb, "hash assignment should not zap weak refs"; + undef %tb; + is $p, \%tb, "hash undef should not zap weak refs"; +}