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
strange behaviour (difference between perl 5.6 and perl 5.8.0) in the regexp #5960
Comments
From infu@bastun.netthis script: $s = "something and another\n"; Outputs in perl 5.8.0 this difference somekind-a sucks but I guess it's not an error. |
From @hvds"Brain Sucker" (via RT) <perlbug@perl.org> wrote: It turns out that executing the empty block results in the last I'm not sure what changed since 5.6 to cause that, but we used to Hugo |
From @andk
> crypt% perl -wle '$_ = "foo"; s/.//eg; print' > I'm not sure what changed since 5.6 to cause that, but we used to Blame: 11822 ----Program---- ----Output of /usr/local/perl-5.7.2@11821/bin/perl--- ----EOF ($?='0')---- ----EOF ($?='11')---- -- |
From @hvdsandreas.koenig@anima.de (Andreas J. Koenig) wrote: Thanks muchly. It turns out that patch, by replacing an empty block with a nextstate, It also changes the error message (again) for lvalue subroutines, so If no-one sees a disaster waiting to happen in this, I'll apply it in Hugo Inline Patch--- op.c.old Tue Oct 22 19:14:24 2002
+++ op.c Sun Nov 3 16:19:22 2002
@@ -1756,9 +1756,14 @@
{
int needblockscope = PL_hints & HINT_BLOCK_SCOPE;
line_t copline = PL_copline;
- /* there should be a nextstate in every block */
- OP* retval = seq ? scalarseq(seq) : newSTATEOP(0, Nullch, seq);
- PL_copline = copline; /* XXX newSTATEOP may reset PL_copline */
+ OP* retval = scalarseq(seq);
+ if (!seq) {
+ /* scalarseq() gave us an OP_STUB */
+ retval->op_flags |= OPf_PARENS;
+ /* there should be a nextstate in every block */
+ retval = newSTATEOP(0, Nullch, retval);
+ PL_copline = copline; /* XXX newSTATEOP may reset PL_copline */
+ }
LEAVE_SCOPE(floor);
PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
if (needblockscope)
--- pp_hot.c.old Sat Oct 19 16:21:46 2002
+++ pp_hot.c Sun Nov 3 16:11:28 2002
@@ -2317,8 +2317,9 @@
PL_curpm = newpm;
LEAVE;
LEAVESUB(sv);
- DIE(aTHX_ "Can't return a %s from lvalue subroutine",
- SvREADONLY(TOPs) ? "readonly value" : "temporary");
+ DIE(aTHX_ "Can't return %s from lvalue subroutine",
+ SvREADONLY(TOPs) ? (TOPs == &PL_sv_undef) ? "undef"
+ : "a readonly value" : "a temporary");
}
else { /* Can be a localized value
* subject to deletion. */
--- t/op/sub_lval.t.old Wed Apr 10 03:23:52 2002
+++ t/op/sub_lval.t Sun Nov 3 16:20:19 2002
@@ -251,7 +251,7 @@
EOE
print "# '$_'.\nnot "
- unless /Empty array returned from lvalue subroutine in scalar context/;
+ unless /Can't return undef from lvalue subroutine/;
print "ok 31\n";
sub lv10 : lvalue {}
@@ -274,7 +274,7 @@
EOE
print "# '$_'.\nnot "
- unless /Can\'t return a readonly value from lvalue subroutine/;
+ unless /Can't return undef from lvalue subroutine/;
print "ok 33\n";
$_ = undef;
--- ext/B/B/Concise.pm.old Sat Aug 17 03:04:42 2002
+++ ext/B/B/Concise.pm Sun Nov 3 15:55:48 2002
@@ -533,7 +533,7 @@
# Why these are different for MacOS? Does it matter?
my $cop_seq_mnum = $^O eq 'MacOS' ? 12 : 11;
-my $seq_mnum = $^O eq 'MacOS' ? 100 : 84;
+my $seq_mnum = $^O eq 'MacOS' ? 102 : 86;
$cop_seq_base = svref_2object(eval 'sub{0;}')->START->cop_seq + $cop_seq_mnum;
$seq_base = svref_2object(eval 'sub{}')->START->seq + $seq_mnum;
--- t/op/closure.t.old Sun Nov 3 16:35:18 2002
+++ t/op/closure.t Sun Nov 3 16:31:13 2002
@@ -13,7 +13,7 @@
use Config;
-print "1..173\n";
+print "1..174\n";
my $test = 1;
sub test (&) {
@@ -527,3 +527,10 @@
}->();
test {1};
+# [perl #17605] found that an empty block called in scalar context
+# can lead to stack corruption
+{
+ my $x = "foooobar";
+ $x =~ s/o//eg;
+ test { $x eq 'fbar' }
+} |
From @hvdshv@crypt.org wrote: Now applied as #18118. Hugo |
@rspier - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#17605 (status was 'resolved')
Searchable as RT17605$
The text was updated successfully, but these errors were encountered: