diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-15 22:30:07 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-15 23:04:29 -0700 |
commit | 4dc304e02d3569a2fbb0907ff3c68656236a547e (patch) | |
tree | 2ec491d83f7b301305c578c07929fc1566fa62c6 | |
parent | bbc28bfcb28b9d71e008cccad034eca23843d3e0 (diff) | |
download | perl-4dc304e02d3569a2fbb0907ff3c68656236a547e.tar.gz |
[perl #97076] Fix mad+threads bareword strict exemption
As reported in the ticket this was broken by:
commit eb796c7f1a47acbd996034731639c1bb76e31a19
Author: Gerard Goossen <gerard@ggoossen.net>
Date: Tue Aug 9 20:35:06 2011 +0200
Move bareword checking from the peephole optimizer to finalize_optree. Fixes [perl #95998]
The bareword checking is moved from the peephole optimizer to finalize_optree.
newRANGE needs additional bareword checking because the constants may
be optimized away by 'gen_constant_list'.
The OPpCONST_STRICT flag is removed after giving an error about a
bareword to prevent giving multiple errors about the same bareword.
In some cases, like pipe(foo,bar), the bareword was subject to strict
'subs' even though it was meant to be exempt.
A backtrace revealed that it happened in S_finalize_op when called
recursively from this block:
#if defined(PERL_MAD) && defined(USE_ITHREADS)
{
/* Make sure mad ops are also thread-safe */
MADPROP *mp = o->op_madprop;
while (mp) {
if (mp->mad_type == MAD_OP && mp->mad_vlen) {
OP *prop_op = (OP *) mp->mad_val;
/* We only need "Relocate sv to the pad for thread safety.", but this
easiest way to make sure it traverses everything */
finalize_op(prop_op);
}
mp = mp->mad_next;
}
}
#endif
That comment about only needing to relocate the sv to the pad is
telling. If that’s the only reason for the recursive call, then
we don’t want that recursive call doing strict checking. So this
commit simply turns off the strict flag, which should be safe, since
S_no_bareword_allowed does the same thing itself.
-rw-r--r-- | op.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1474,6 +1474,8 @@ S_finalize_op(pTHX_ OP* o) OP *prop_op = (OP *) mp->mad_val; /* We only need "Relocate sv to the pad for thread safety.", but this easiest way to make sure it traverses everything */ + if (prop_op->op_type == OP_CONST) + cSVOPx(prop_op)->op_private &= ~OPpCONST_STRICT; finalize_op(prop_op); } mp = mp->mad_next; |