From 3aadd5cd55cb7dedef11ffce3eef74f924ccd1bb Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 8 Dec 2010 11:11:07 -0800 Subject: [PATCH] [perl #19135] string eval turns off readonlyness on lexicals MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Don’t turn off readonliness on lexicals when freeing pad entries. The readonliness is (prior to this commit) turned off explicitly in pad_free under ithreads. See also bug #19022, which resulted from the same change. There is some discussion there, too, but nobody seemed to know exactly why the readonliness needed to be turned off. Change 4761/2aa1bed, from January of 2000, added that SvREADONLY_off. It is supposed to make sure that pad entries that were constants will not be constants the next time they are used. Dave Mitchell writes: > I think...[this]...fix is correct (just removing the SvREADONLY_off). > The issue it was trying to fix appears to have been properly fixed > later by 3b1c21fabed159100271bd60bac3f870f5ac16af, which is why it's > safe to remove it. So this commit just deletes that code. --- pad.c | 5 ----- t/op/eval.t | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pad.c b/pad.c index 9b8cda5..8ab34ff 100644 --- a/pad.c +++ b/pad.c @@ -1450,11 +1450,6 @@ Perl_pad_free(pTHX_ PADOFFSET po) if (PL_curpad[po] && PL_curpad[po] != &PL_sv_undef) { SvPADTMP_off(PL_curpad[po]); -#ifdef USE_ITHREADS - /* SV could be a shared hash key (eg bugid #19022) */ - if (!SvIsCOW(PL_curpad[po])) - SvREADONLY_off(PL_curpad[po]); /* could be a freed constant */ -#endif } if ((I32)po < PL_padix) PL_padix = po - 1; diff --git a/t/op/eval.t b/t/op/eval.t index 0a5fadc..a1c1c1a 100644 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -print "1..107\n"; +print "1..108\n"; eval 'print "ok 1\n";'; @@ -611,3 +611,9 @@ eval $ov; print "ok\n"; EOP +for my $k (!0) { + eval 'my $do_something_with = $k'; + eval { $k = 'mon' }; + is "a" =~ /a/, "1", + "string eval leaves readonly lexicals readonly [perl #19135]"; +} -- 2.7.4