-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
string eval turns off readonlyness on lexicals #6160
Comments
From @nwc10Created by @nwc10Without ithreads, a lexical stays readonly when it is referenced inside $ perl5.8.0-32 -MDevel::Peek -wle 'my $k = "!"; Internals::SvREADONLY $k, 1; Dump $k; eval "print \$k"; Dump $k' With ithreads it loses its readonlyness: perl5.8.0-32-i -MDevel::Peek -wle 'my $k = "!"; Inter This is still true in blead. It seems wrong. (It's also the source of a I think it's the code at the line /* could be a freed constant */ in Perl Info
|
From @schwernConfirmed to still exist in 5.8.6 and blead. |
The RT System itself - Status changed from 'new' to 'open' |
From @chornySame result on 5.12.0 with ithreads. On Sat Dec 14 11:15:57 2002, nicholas wrote:
-- |
From [Unknown Contact. See original ticket]Same result on 5.12.0 with ithreads. On Sat Dec 14 11:15:57 2002, nicholas wrote:
-- |
From @cpansproutThe readonliness is 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. My question is: When the addresses of those scalars are reused, won’t the scalars be wiped clean? (In case it’s not obvious, I have very little idea how pads actually work.) I tried simply deleting that SvREADONLY_off, and all tests pass (see the first attached patch). Then I thought that maybe I should check that the SV is freed, and only then do SvREADONLY_off, to preserve the original intent of change 4761/2aa1bed. That worked too. So, here are two patches. Take your pick. |
From @cpansproutFrom: Father Chrysostomos <sprout@cpan.org> [perl #19135] string eval turns off readonlyness on lexicals Don’t turn off readonliness on lexicals when freeing pad entries. Inline Patchdiff -up blead/pad.c blead-19135-readonly-lexicals/pad.c
--- blead/pad.c 2010-09-12 04:32:10.000000000 -0700
+++ blead-19135-readonly-lexicals/pad.c 2010-09-14 16:13:03.000000000 -0700
@@ -1386,11 +1386,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 -rup blead/t/op/eval.t blead-19135-readonly-lexicals/t/op/eval.t
--- blead/t/op/eval.t 2010-07-03 08:47:11.000000000 -0700
+++ blead-19135-readonly-lexicals/t/op/eval.t 2010-09-14 16:23:18.000000000 -0700
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-print "1..107\n";
+print "1..108\n";
eval 'print "ok 1\n";';
@@ -611,3 +611,10 @@ eval $ov;
print "ok\n";
EOP
+{
+ my $k = "!";
+ Internals::SvREADONLY $k, 1;
+ eval 'my $do_something_with = $k';
+ eval { $k = 'mon' };
+ is $k, "!", "string eval leaves readonly lexicals readonly [perl #19135]";
+} |
From @cpansproutFrom: Father Chrysostomos <sprout@cpan.org> [perl #19135] string eval turns off readonlyness on lexicals Don’t turn of readonliness on lexicals when freeing pad entries, Inline Patchdiff -up blead/pad.c blead-19135-readonly-lexicals/pad.c
--- blead/pad.c 2010-09-12 04:32:10.000000000 -0700
+++ blead-19135-readonly-lexicals/pad.c 2010-09-14 16:13:59.000000000 -0700
@@ -1387,8 +1387,7 @@ 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]))
+ if (SvIS_FREED(PL_curpad[po]))
SvREADONLY_off(PL_curpad[po]); /* could be a freed constant */
#endif
}
diff -rup blead/t/op/eval.t blead-19135-readonly-lexicals/t/op/eval.t
--- blead/t/op/eval.t 2010-07-03 08:47:11.000000000 -0700
+++ blead-19135-readonly-lexicals/t/op/eval.t 2010-09-14 16:23:18.000000000 -0700
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-print "1..107\n";
+print "1..108\n";
eval 'print "ok 1\n";';
@@ -611,3 +611,10 @@ eval $ov;
print "ok\n";
EOP
+{
+ my $k = "!";
+ Internals::SvREADONLY $k, 1;
+ eval 'my $do_something_with = $k';
+ eval { $k = 'mon' };
+ is $k, "!", "string eval leaves readonly lexicals readonly [perl #19135]";
+} |
From @cpansproutOn Sun Sep 19 12:10:11 2010, sprout wrote:
Has anyone in the know had a chance to review these yet? |
From @cpansproutOn Sun Sep 26 12:46:49 2010, sprout wrote:
Well...? :-) Here is a better test case, with no Internals:: stuff: $ perl5.13.5 -wle 'for my $k(!0) { eval "\$k"; eval { $k = 7 }; print |
From [Unknown Contact. See original ticket]On Sun Sep 26 12:46:49 2010, sprout wrote:
Well...? :-) Here is a better test case, with no Internals:: stuff: $ perl5.13.5 -wle 'for my $k(!0) { eval "\$k"; eval { $k = 7 }; print |
From @iabynOn Sun, Nov 28, 2010 at 01:39:18PM -0800, Father Chrysostomos via RT wrote:
I think the first fix is correct (just removing the SvREADONLY_off). The second fix is wrong, in that the SVs in the pad aren't freed in the -- |
From @cpansproutOn Mon Dec 06 07:40:09 2010, davem wrote:
I’ve just applied a slightly modified version as 3aadd5c. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#19135 (status was 'resolved')
Searchable as RT19135$
The text was updated successfully, but these errors were encountered: