| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
This code, added recently in 4c3ac4b and amended in 837c879, has been
unnecessary since commit 75ea7a1.
|
|
|
|
|
| |
This code, added recently in 7d779b2, has been unnecessary since com-
mit 75ea7a1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is only part of #87708.
This fixes the + operator outside of any ‘use integer’ scope when the
same tied scalar is used for both operands and returns two different
values. Before this commit, get-magic would be called only once and
the same value used. In 5.12.x it just worked.
I tried modifying pp_eq throughout to take this case into account,
but it made the most common cases slightly slower, presumably because
of the extra checks. So this follows the same temp sv method that I
used for pp_add (in 4c3ac4b and 837c879), which, though slowing down
this edge cases due to the extra allocation, leaves the most common
cases just as fast. (And, in case my benchmarks were unreliably [not
unlikely], this method is also safer, as it has less chance of getting
different code paths wrong.)
|
|
|
|
|
|
|
| |
Allocating an extra SV for rare edge cases...er...only needs to be
done in those rare edge cases.
Uninitialized warnings are only supposed to be enabled when they are.
|
|
|
|
|
|
|
|
|
| |
This is just part of #87708.
This fixes the + operator outside of any ‘use integer’ when the same
tied scalar is used for both operands and returns two different val-
ues. Before this commit, get-magic would be called only once and the
same value used. In 5.12.x it worked.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to obscure closure and goto tricks, it's sometimes possible for the
array or hash in the LHS of 'my @a = ...' and 'my %h = ...' to be
non-empty. At compile-time, these conditions are detected and the assign
op is compiled with the OPpASSIGN_COMMON, making the assignment slower.
This commit speeds it up again by adding a run-time check to pp_aassign
to only do the OPpASSIGN_COMMON code-branch if the LHS isn't an empty
array or hash.
See also #70171.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As reported at nntp://nntp.perl.org/1298599236.4753.72.camel@p100 (and
respaced for readability):
#!perl5.12.0
$r=q/
print __FILE__;
local *dbline = $main::{"_<".__FILE__};
print $dbline[0]
/;
eval $r;'
__END__
(eval 1)
Bus error
This only seems to happen in non-threaded perls.
It can be reduced to this:
*d = *a; print $d[0];
The $d[0] is optimised into an aelemfast op (instead of the usual aelem
with an rv2av kid). pp_aelemfast is at fault, as evidenced by the fact
that this does not crash (the ${\...} prevents the optimisation):
*d = *a; print $d[${\0}];
pp_aelemfast uses GvAV instead of GvAVn. Usually $d[0] will autovivify
@d, but the glob assignment leaves $d[0] pointing to a glob (*d) with
no array. Then pp_alemfast passes a null pointer around.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Now that REGEX is actually a first-class SV type, we can taint
the regex SV directly, as well as the RV pointing to it.
This means that this now taints:
$rr = qr/$tainted/;
$r = $$r;
/$r/;
|
|
|
|
|
|
|
|
| |
If the match fails, don't bother to execute some code that prepares the
source and replacement strings for a substitution (e.g. matching
UTF8-ness).
(This is an enhancement to ff6e92e827a143094fdf3af374056b524759194b)
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a re-implementation of the tainting code in pp_subst and
pp_substcont. Although this fixes many bugs, because its a de-novo rewrite
of the tainting parts of the code in those two functions, it's quite
possible that it breaks some existing tainting behaviour. It doesn't break
any existing tests, although it turns out that this area was severely
under-tested anyway.
The main bugs that this commit fixes are as follows, where:
T = a tainted value
L = pattern tainted by locale (e.g. use locale; s/\w//)
Happens both with and without 'use re taint' unless specified.
Happens with all modifiers (/g, /r etc) unless explicitly mentioned.
$1 unexpectedly untainted:
s/T//
T =~ s/// under use re 'taint'
original string unexpectedly untainted:
s/L//, s/L//g
return value unexpectedly untainted:
T =~ s///g under no re 'taint'
s/L//g, s/L//r
return value unexpectedly tainted:
s/T//
s//T/r under no re 'taint'
T =~ s/// under use re 'taint'
s//T/ under use re 'taint'
Also, with /ge, the original string becomes tainted as soon as possible
(usually in the second entry to the /e code block) rather than only at the
end, in code like
$orig =~ s/T/...code.../ge
The rationale behind the taintedness of the return value of s/// (in the
non /r case), is that a boolean value shouldn't be tainted. This
corresponds to the general perl tainting policy that boolean ops don't
return tainted values. On the other hand, when it returns an integer
(number of matches), that should be tainted.
A couple of note about the old tainting code this replaces: firstly, several
occurrences of the following were NOOPs, since rxtainted was U8 and the bit
being ored was > 256:
rxtainted |= RX_MATCH_TAINTED(rx)
secondly, removing a whole bunch of the following didn't make any
existing tests fail:
TAINT_IF(rxtainted & 1);
|
|
|
|
|
| |
'play_it_again:' was on column 0, which meant that most diff
utilities interpreted it as a function name.
|
|
|
|
|
| |
The last few commits have been working towards making two
blocks of code identical. Now it's payback time!
|
|
|
|
|
|
| |
This should leave things functionally unchanged.
This is another step in making two branches of code more identical
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 3e462cdc2087ddf90984010fabd80c30db92bfa0 provided a fix
for the s/non-utf8/is-utf8/ case by upgrading TARG to UTF8 after the
match, but before the substitution. It used sv_utf8_upgrade() rather than
sv_utf8_upgrade_nomg(), so for example, with a tied variable, FETCH would
get called again, and all the char* pointers such as s would be left
dangling. If the length of the string was unchanged, the code wouldn't
notice this.
Fix by using the _nomg() variant, and by checking whether the string
has been reallocated
|
|
|
|
|
|
|
| |
These were added around a mg_set() call before the stack-of-stacks
mechanism was introduced, which has made them redundant.
This is another step in making two branches of code more identical
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are two main branches in pp_subtr(): the 'in-place' and the other,
depending on whether the replacement string is short enough to be inserted
directly. Commit 80b498e0aacf413fb7460d6882a74c68c1f9df48 back in 2000
changed a SvPOK_only() to a SvPOK_only_UTF8() to preserve the UTF8 bit,
but only on *one* branch. Add the change to the other branch too. This
will only make a difference in rare cases involving 'use bytes' (where it's
arguably broken and generating malformed utf8 anyway); but the main
reason for doing it is to allow soon for some identical code in the two
branches to be de-duplicated.
|
| |
|
| |
|
|
|
|
| |
(both nope: and ret_no: labelled the same chunk of exit code)
|
|
|
|
|
| |
... rather than messing about first deciding whether to process
a successful match inline or not
|
| |
|
|
|
|
| |
just a white space change
|
|
|
|
|
|
|
| |
It now generates prototypes for all functions that implement OPs. Hence
Perl_unimplemented_op no longer needs a special-case prototype. As it is now
generating a prototype for Perl_do_kv, no need for regen/embed.pl to duplicate
this. Convert the last two users of the macro do_kv() to Perl_do_kv(aTHX).
|
|
|
|
|
|
|
|
|
|
|
| |
Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13
locations that relied on them.
regen/opcode.pl now generates prototypes for the PP functions directly, into
pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads
this, removing the only ordering dependency in the regen scripts. opcode.pl
is now responsible for prototypes for pp_* functions. (embed.pl remains
responsible for ck_* functions, reading from regen/opcodes)
|
|
|
|
|
|
|
|
|
| |
# New Ticket Created by (Peter J. Acklam)
# Please include the string: [perl #81904]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 >
Signed-off-by: Abigail <abigail@abigail.be>
|
| |
|
|
|
|
|
| |
Add a flag TIED_METHOD_SAY to Perl_tied_method(), to allow tied PRINT to
effect C<local $\ = "\n";> within the ENTER/LEAVE pair of Perl_tied_method().
|
| |
|
|
|
|
|
|
| |
Simplify tests of !gv || !io to just !io, avoid calling GvIO(gv) more than
once, and where possible initialise io at declaration time, to allow it to be
const.
|
|
|
|
|
|
|
|
| |
Due to the way that '<> as glob' was parsed differently from
'<> as filehandle' from 5.6 onwards, something like <$foo[0]>
didn't handle overloading, even where $foo[0] was an overloaded object.
This was contrary to the docs for overload, and meant that <> couldn't
be used as a general overloaded iterator operator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some amagic-related macros take the full method enumeration name,
(e.g. "add_amg"); while others "helpfully" allow you to pass a shortened
version, ("add"), and do a CAT2(meth,_amg) behind the scenes.
Standardise on passing the full name; this makes it less confusing and
allows you to grep for the enumeration name in the source.
It updates two macros to accept full enumeration names: tryAMAGICunTARGET
(which isn't used outside the core apparently), and AMG_CALLun, which is
replaced by a new AMG_CALLunary (since AMG_CALLun is used outside the
core).
|
|
|
|
|
|
|
|
|
|
| |
This trades reduced code size for an extra function call in the error path with
warnings disabled. (And removes a duplicated check for the case of taking the
error path *with* warnings enabled.)
Removing the check from Perl_do_close() does not change behaviour, as io is
NULL there, hence Perl_report_evil_fh() will always be checking WARN_UNOPENED
and setting vile to "unopened".
|
|
|
|
|
|
| |
This trades reduced code size for an extra function call in the error path with
warnings disabled. (And removes a duplicated check for the case of taking the
error path *with* warnings enabled.)
|
| |
|
| |
|
|
|
|
|
| |
Previously Perl_report_evil_fh()'s body was just an if/else at the top level -
a good sign that it is actually implementing two disjoint functions.
|
| |
|
|
|
|
|
|
|
|
| |
(if we can avoid it).
Fix for RT #77456. Basically it extends the usage of the AMGf_numeric flag
to the remaining overloadable numeric ops that behave differently with IV
and NV.
|
|
|
|
|
| |
Something else changed unnecessarily by 541ed3a9. I really oughtn’t do
this when I’ve been awake for more than 18 hours....
|
|
|
|
|
| |
That was part of my first attempt to fix [perl #68560]. I forgot to
delete it. (It’s harmless.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a closure is created, the original sub is cloned (except that the
op tree is shared). That original sub (called the closure prototype)
is not usually accessible to perl.
An attribute handler (MODIFY_CODE_ATTRIBUTES) is passed a reference
to it, however. If that code reference is called within the attribute
handler, an ‘Undefined subroutine called’ error results, because the
op tree has not been attached yet.
If that code reference is stashed away and called after the attribute
handler returns, it will most likely crash.
This is because its pad is full of nulls.
A regular $proto->() or &$proto() call that sets up @_ will crash in
attempting to do so.
A &$proto call will bypass that, but attempting to read any lexical
variables from the containing scope will cause a crash. Any operator
that uses TARG (i.e., most of them) will crash.
So this commit puts a check for closure prototypes in pp_entersub. It
produces a new error message, ‘Closure prototype called’.
This does introduce a backward-incompatible change: code like this
used to work:
sub MODIFY_CODE_ATTRIBUTES { $'proto = $_[1] }
{ my $x; () = sub :attr { () = $x; print "hello\n" } }
&$'proto;
But writing a useful subroutine that tiptoes past the crashes is so
difficult that I think this breakage is acceptable.
|
|
|
|
|
|
|
| |
padav is leaving an arrayref on the stack when producing the return value for an
lvalue sub. But when this is in an argument list it really should be a array,
not a ref. So, in leavesublv I check for this case and expand the arrayref to
an array.
|
|
|
|
| |
Nothing outside the core was using this macro.
|
| |
|
|
|
|
|
| |
Calling a subref whose value was PL_sv_yes, and without args,
failed to pop an entry off the mark stack
|
|
|
|
|
| |
sv_utf8_upgrade_nomg() may reallocate the stack via sv_recode_to_utf8()
if 'use encoding' is in effect, causing stack pointer corruption.
|
|
|
|
|
|
|
|
|
| |
This reverts commit 0fe688f528b0e1b5bef6fb30d5e45316430e8a41, except
for the tests.
It is no longer necessary, as of change 2acc3314e31a9. Another reason
for this revert is that doing so fixes bug #77812, or at least it
would if 2acc3314e31a9 had not fixed that, too.
|