diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-05 13:26:41 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-05 13:26:41 -0700 |
commit | ab97dcc3bf50e847e83b6a2d0f3b3f7cd43f1cf6 (patch) | |
tree | 08257993e879ddd571e0748941f419721ef034d4 /scope.c | |
parent | 6e593c84d6ec5b4c84f0821bb2a897973a81976f (diff) | |
download | perl-ab97dcc3bf50e847e83b6a2d0f3b3f7cd43f1cf6.tar.gz |
Weak refs to pad hvs should go stale
When a lexical variable goes out of scope, as in
{
my %lexical_variable;
...
}
# no longer in scope here
it is supposed to disappear as far as Perl code can tell. That the
same SV is reused the next time that scope is entered is an implement-
ation detail.
The move of hashes’ back-references from magic into the HvAUX struc-
ture in 5.10 caused this implementation detail to leak through.
Normally, weak references to pad variables going out of scope are
killed off:
{
my $scalar;
weaken ($global_scalar = \$scalar);
}
# here $global_scalar is undef
When hashes’ back-references were moved, leave_scope was not updated
to account. (For non-hash variables, it’s the mg_free call that takes
care of it.) So in this case:
{
my %hash;
weaken ($global_scalar = \%hash);
}
$global_scalar would still reference a hash, but one marked PADSTALE.
Modifications to that hash through the reference would be visible the
next time the scope was entered.
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -911,6 +911,7 @@ Perl_leave_scope(pTHX_ I32 base) av_clear(MUTABLE_AV(sv)); break; case SVt_PVHV: + Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv)); hv_clear(MUTABLE_HV(sv)); break; case SVt_PVCV: |