| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
Extracted from patch submitted by Lajos Veres in RT #123693.
|
|
|
|
|
| |
Previously this would crash in FF_MORE because chophere was still
NULL.
|
| |
|
| |
|
|
|
|
| |
See RT ticket for this patch for details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This;
@a=(0x7ffffffffffffffe..0x7fffffffffffffff);
could produce under ASan:
pp_ctl.c:1212:19: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'IV' (aka 'long')
so avoid post-incrementing the loop var on the last iteration.
This fix is more to shut ASan up than an actual bug, since the
bad value on the last iteration wouldn't actually be used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is also the subject of perl #123071.
The iteration count was stored in an I32 and was overflowing. If the
maximum number of iterations possible overflowed, then it would become
negative, and the substitution would fail immediately with ‘Substitu-
tion loop’.
I tried fixing this without increasing the size of the context
stack entries on 64-bit builds (by skipping the loop check for long
strings), but was unable to, because we have to return the number of
iterations, which was also stored as I32. If we change just that one
to SSize_t, we get an I32-sized alignment hole, so we might as well
make maxiters a SSize_t as well, fixing the bug that way (the more
straightforward way).
|
|
|
|
|
|
|
|
|
|
|
| |
This shrinks the machine code.
Before and after:
$ ls -l pp_ctl.o
-rw-r--r-- 1 sprout staff 96156 Dec 19 16:05 pp_ctl.o
$ ls -l pp_ctl.o
-rw-r--r-- 1 sprout staff 96044 Dec 19 16:09 pp_ctl.o
|
|
|
|
|
|
|
|
|
| |
GIMME_V is a simpler macro that results in smaller machine code.
GIMME does not distinguish between scalar and void context. The two
instances of GIMME == G_SCALAR that I changed (which used to match
void context too, but no longer do) are in code paths unreachable in
void context, so we don’t need to check for it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes two issues:
1) if you don't supply enough arguments to the format, pp_formline()
uses &PL_sv_no as the sv, since we've already warned about the
missing format argument, we don't need to produce a read only error
for an SV the caller didn't supply
2) when the supplied string is empty for FF_LINESNGL and FF_LINEGLOB
the case would skip most of its processing, including setting
chophere, this meant that when the following FF_CHOP operator was
processed it would pass a pointer into a different string, producing
a panic.
|
|
|
|
|
|
|
|
|
| |
to match the existing convention (OpREFCNT, OpSLAB).
Dave Mitchell asked me to wait until after his multideref work
was merged.
Unfortunately, there are now CPAN modules using OP_SIBLING.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 8771da69db30134352181c38401c7e50753a7ee8.
Pad lists need to carry IDs around with them, so that when something
tries to close over a pad, it is possible to confirm that the right
pad is being closed over (either the original outer pad, or a clone of
it). (See the commit message of db4cf31d1, in which commit I added an
ID to the padlist struct.)
In 8771da69 I found that I could use the memory address of the pad’s
name list (name lists are shared) and avoid the extra field.
Some time after 8771da69 I realised that a pad list could be freed,
and the same address reused for another pad list, so using a memory
address may not be so wise. I thought it highly unlikely, though, and
put it on the back burner.
I have just run into that. t/comp/form_scope.t is now failing
for me with test 13, added by db4cf31d1. It bisects to 3d6de2cd1
(PERL_PADNAME_MINIMAL), but that’s a red herring. Trivial changes
to the script make the problem go away. And it only happens on non-
debugging builds, and only on my machine. Stepping through with gdb
shows that the format-cloning is following the format prototype’s out-
side pointer and confirming that it is has the correct pad (yes, the
memory addresses are the same), which I know it doesn’t, because I can
see what the test is doing.
While generation numbers can still fall afoul of the same problem, it
is much less likely.
Anyway, the worst thing about 8771da69 is the typo in the first word
of the commit message.
|
|
|
|
| |
In particular, remove all instances of 'assert(0);'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 2433d39e6 (require should die if a file exists but can't be
read) made first failed opened file fatal as request in
[perl #113422]. However error message produced in that case is not
much helpful in identifying which file ound not been accessed:
$ LANG=C perl -I/root -e 'require strict'
Can't locate strict.pm: Permission denied at -e line 1.
This patch adds the name of the failed file to the message to help
identify which @INC directory is erroneous:
$ LANG=C ./perl -I/root -I./lib -e 'require strict'
Can't locate strict.pm: /root/strict.pm: Permission denied at -e line 1.
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The encoding pragma is deprecated, but in the meantime it causes spooky
action at a distance with other modules that it may be combined with.
In these modules, operations such as chr(), ord(), and utf8::upgrade()
will suddenly start doing the wrong thing.
The documentation for 'encoding' has said to call it after loading other
modules, but this may be impractical. This is especially bad with
anything that auto-loads at first use, like \N{} does now for charnames.
There is an issue with combining this with setting the variable
${^ENCODING} directly. The potential for conflicts has always been
there, and remains. This commit introduces a shadow hidden variable,
subservient to ${^ENCODING} (to preserve backwards compatibility) that
has lexical scope validity.
The pod for 'encoding' has been revamped to be more concise, clear, use
more idiomatic English, and to speak from a modern perspective.
|
|
|
|
|
| |
The offset in op_targ is sufficient. The next commit will take advan-
tage of this.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
before 0xA08 bytes of machine code on miniperl VC2003, after 0x9B0
All 3 exit/return paths of pp_goto call PERL_ASYNC_CHECK, but due to
subtle differences between them, they were 3 separate branches in machine
code that shared nothing. In the first, a plain C return was done instead
of a RETURNOP (which contains "PL_stack_sp = sp"). In the 2 RETURNOPs, one
returned a OP * from a CV*, the other returned a C auto. They couldn't be
fused therefore, since PERL_ASYNC_CHECK could, according to C lang,
rewrite CvSTART. To fix this, reorder the order of operations so 1 instance
of PERL_ASYNC_CHECK is shared by the 3 different exit paths. Also due to
the "if (!(do_dump || label_len)) DIE" it is impossible to not run one or
the other. The isolated if(do_dump) and if(label_len), mean that unless
a C optimizer was very smart (VC wasnt), there was an control path where
PERL_ASYNC_CHECK would execute twice in row. Remove that control path
explicitly. There might be questionable stack usage/stack reallocation
near PERLDB_GOTO but I am not looking for that in this patch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
CvRESERVED is a placeholder, it will be replaced with a sentinal value
from future revised BOOTCHECK API.
CvPADLIST_set was helpful during development of this patch, so keep it
around for now.
PoisonPADLIST's magic value is from PERL_POISON 0xEF pattern. Some
PoisonPADLIST locations will get code from future BOOTCHECK API.
Make padlist_dup a NN function to avoid overhead of calling it for XSUBs
during closing.
Perl_cv_undef_flags's else if (CvISXSUB(&cvbody)) is to avoid whitespace
changes.
Filed as perl [#123059].
|
|
|
|
| |
Some passing tests are still marked to-do. We need more tests still.
|
|
|
|
|
|
|
|
|
| |
This prevents perl recursing infinitely when an overloaded object is
assigned to $DB::single, $DB::trace or $DB::signal
This is done by referencing their values as IVs instead of as SVs in
dbstate, and by adding magic to those variables so that assignments to
the scalars update the PL_DBcontrol array.
|
|
|
|
|
|
|
|
|
|
|
|
| |
See ff2a62e0c8 for the explanation. The bug fix in that commit did
not apply to foreach’s aliasing.
In short, ($a,$b)=($c,$d) needs to account for whether two of those
variable names could be referring to the same variable.
This commit causes the test suite to exercise a code path in scope.c
added by ff2a62e0c8, which turned out to be buggy. (I forgot to test
it at the time.)
|
|
|
|
|
|
|
|
|
|
| |
One of the main purposes of cv_name was to provide a way for CPAN mod-
ules easily to obtain the name of a sub. As written, it was not
actually sufficient, as some modules, such as Devel::Declare, need an
unqualified name.
So I am breaking compatibility with 5.21.4 (which introduced cv_name,
but is only a dev release) by adding a flags parameter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See the previous commit for the explanation. This fixes this
discrepancy:
$ ./miniperl -Ilib -e '+sub:lvalue{my $x = 3; Internals::SvREADONLY $x, 1; $x }->() = 3'
Can't return a readonly value from lvalue subroutine at -e line 1.
$ ./miniperl -Ilib -e '+sub:lvalue{my $x = *foo; Internals::SvREADONLY $x, 1; $x }->() = 3'
Modification of a read-only value attempted at -e line 1.
It was not just a flag check that this commit fixed, but also a bogus
SvREADONLY(TOPs) where TOPs may not even be the scalar we are dying
for, giving ‘a temporary’ for some read-only values. That mistake was
my own, made in commit d25b0d7b8.
|
|
|
|
|
|
|
|
| |
Where pp_foo() also handles OP_BAR, add a comment above the function
mentioning that it also does pp_bar.
This means that "grep pp_bar pp*.c" quickly locates the file/function that
handles OP_BAR.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
commit a2309040b8 added duplicate SvNV calls, remove them. Reorder the
"SvUV_nomg(sv) > (UV)IV_MAX || SvNV_nomg(sv) > (NV)UV_MAX" so the var
will be stored in a FP CPU reg for all comparisons, and not saved/fetched
to/from mem across the SvUV func call. Due to complexity, I am not
unrolling and fusing SvNV_nomg and SvOK.
VC 2003 32b size of func in machine code bytes before 0x4d3 after 0x4a2
|
|
|
|
|
| |
It now does more than that, so use a name that describes when it is
called, rather than what it does.
|
|
|
|
|
|
|
|
| |
All callers of S_adjust_stack_on_leave had TAINT_NOT before the call to
S_adjust_stack_on_leave. Factor it into the func to make the callers
smallers machine code wise. More things can be factored out into
adjust_stack_on_leave from its callers, but this particular change is very
easy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 60779a30f stopped setting PADTMP on GVs in pads,
and changed many instances of if(SvPADTMP && !IS_PADGV) to
if(SvPADTMP){assert(!IS_PADGV)...}.
This PADTMP was leftover from the original ithreads implementation
that marked these as PADTMP under the assumption that anything in a
pad had to be marked PADMY or PADTMP.
Since we don’t want these GVs copied the way operator targets are
(PADTMP indicates the latter), we needed this !IS_PADGV check all over
the place.
60779a30f was actually right in removing the flag and the !IS_PADGV
check, because it should be possible for XS modules to create ops that
return copiable GVs. But the assertions prevent that from working.
More importantly (to me at least), this IS_PADGV doesn’t quite make
sense and I am trying to eliminate it.
BTW, you have to be doubly naughty, but it is possible to fail these
assertions:
$ ./perl -Ilib -e 'BEGIN { sub { $::{foo} = \@_; constant::_make_const(@_) }->(*bar) } \ foo'
Assertion failed: (!IS_PADGV(sv)), function S_refto, file pp.c, line 576.
Abort trap: 6
|
|
|
|
|
|
|
|
|
|
| |
Commit ae77754ae caused it to start including the package name. Pre-
viously, lexical subs were reported as ‘(unknown)’.
Now we have more expected output:
$ ./perl -Ilib -XMfeature=:all -e 'my sub x{warn +(caller 0)[3]} x'
x at -e line 1.
|
|
|
|
| |
What was I thinking?
|
|
|
|
|
|
|
|
| |
This was added years ago in commit 7fb6a879. Now that save_re_context
does nothing (and die_unwind no longer even calls it), we don’t need to
assign to PL_curcop. In the case where it matters, that is, the implicit
eval scope that require provides, the values of PL_curcop and oldcop
should always be the same.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As of f04d2c345 perl does not give uninitialized warnings for ‘require
undef’. But the check was not happening soon enough, causing tied
variables to behave erratically:
$ ./perl -Ilib -we 'sub TIESCALAR{bless[]}sub FETCH{undef}sub STORE{}tie $x,""; $x="a"; require $x'
Use of uninitialized value $x in require at -e line 1.
Missing or undefined argument to require at -e line 1.
(Uninit warning where muggle variables lack one.)
$ ./perl -Ilib -we 'sub TIESCALAR{bless[]}sub FETCH{undef}sub STORE{}tie $x,""; $x=3; require $x'
Invalid version format (non-numeric data) at -e line 1.
(undef being treated as a version string.)
We have to call get-magic on the argument before we check its
definedness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
in Perl 5.14 the following segfaults:
*CORE::GLOBAL::require = sub { }; eval "require";
in Perl 5.18
perl -wle'eval "require";'
produces a spurious warning:
Use of uninitialized value $_ in require at (eval 1) line 1.
In other perls:
perl -e 'eval q/require $this/ or print $@'
produces:
Null filename used at (eval 1) line 1.
The error message is crappy, totally unfit for a perl audience,
and the spurious warning is just confusing. There is no $_ in use
here, why do we warn about it.
It looks like 9e3fb20c fixed the segfault (by accident), and also
somehow meant that the "Null filename" error would not ever be
produced.
So this patch ditches the crappy error and replaces it with something
meaningful and informative, and tests that we do not regress and start
segfaulting again.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add the boolean field op_lastsib to OPs. Within the core, this is set
on the last op in an op_sibling chain (so it is synonymous with op_sibling
being null). By default, its value is set but not used.
In addition, add a new build define (not yet enabled by default),
-DPERL_OP_PARENT, that forces the core to use op_lastsib to detect the
last op in a sibling chain, rather than op_sibling being NULL. This frees
up the last op_sibling pointer in the chain, which rather than being set
to NULL, is now set to point back to the parent of the sibling chain (if
any).
This commit also adds a C-level op_parent() function and B parent()
method; under default builds they just return NULL, under PERL_OP_PARENT
they return the parent of the current op.
Collectively this provides a facility not previously available from B:: nor
C, of being able to follow an op tree up as well as down.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove (almost all) direct access to the op_sibling field of OP structs,
and use these three new macros instead:
OP_SIBLING(o);
OP_HAS_SIBLING(o);
OP_SIBLING_set(o, new_value);
OP_HAS_SIBLING is intended to be a slightly more efficient version of
OP_SIBLING when only boolean context is needed.
For now these three macros are just defined in the obvious way:
#define OP_SIBLING(o) (0 + (o)->op_sibling)
#define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling))
#define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib))
but abstracting them out will allow us shortly to make the last pointer in
an op_sibling chain point back to the parent rather than being null, with
a new flag indicating whether this is the last op.
Perl_ck_fun() still has a couple of direct uses of op_sibling, since it
takes the field's address, which is not covered by these macros.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
RT #122148: In 5.20, commit 25fdce4a165 changed the way pos() was stored
in magic attached to SVs from being a byte offset to a char offset,
*except* that, for efficiency, strings being used for pattern matching
were kept as byte offsets (with a flag indicating thus), *except* where
the SV already had magic attached (such as taint, as in the bug report and
in this commit's test), in which case it kept it as chars.
The code that updated pos() after an iteration of s///e was faulty: the
string buffer it used for converting byte legnths to char lengths (via
utf8_length()) was the wrong buffer: rather than using the src string
being matched against, it was using the destination string being built up
via iterations of s///. Once double-byte utf8 chars were involved, all the
pos() calculations went wrong, and utf8 warnings started mysteriously
appearing.
|
| |
|
|
|
|
|
|
|
|
| |
You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT
or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference.
(g++ does not do the "post-annotation" form of "unused".)
The version code has some of these issues, reported upstream.
|
|
|
|
|
|
|
| |
A bit dubious to ignore the snprintf results, but at least
for these cases it looks acceptable. We could assign the
length and croak if not expected, but it seems that with
gcc brace groups we already do that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For S_ functions, remove the context.
For Perl_ functions, add PERL_UNUSED_CONTEXT.
Tricky because sometimes depends on DEBUGGING, and sometimes
on whether we are have PERL_IMPLICIT_SYS.
(Why all the mathoms Perl_is_uni_... and Perl_is_utf8_...
functions are not being whined about is a mystery.)
vutil.c (included via util.c) has one of these, but it's cpan/,
and a known problem: https://rt.cpan.org/Ticket/Display.html?id=96100
|
|
|
|
|
|
| |
This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca.
(Still needs more work, but wanted to see how well this passed with Jenkins.)
|
|
|
|
|
|
| |
Definitely not *after* it. It marks the start of the unreachable,
not the first unrechable line. And if they are in that order,
it looks better to linebreak after the lint hint.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- after return/croak/die/exit, return/break are pointless
(break is not a terminator/separator, it's a goto)
- after goto, another goto (!) is pointless
- in some cases (usually function ends) introduce explicit NOT_REACHED
to make the noreturn nature clearer (do not do this everywhere, though,
since that would mean adding NOT_REACHED after every croak)
- for the added NOT_REACHED also add /* NOTREACHED */ since
NOT_REACHED is for gcc (and VC), while the comment is for linters
- declaring variables in switch blocks is just too fragile:
it kind of works for narrowing the scope (which is nice),
but breaks the moment there are initializations for the variables
(the initializations will be skipped since the flow will bypass
the start of the block); in some easy cases simply hoist the declarations
out of the block and move them earlier
Note 1: Since after this patch the core is not yet -Wunreachable-code
clean, not enabling that via cflags.SH, one needs to -Accflags=... it.
Note 2: At least with the older gcc 4.4.7 there are far too many
"unreachable code" warnings, which seem to go away with gcc 4.8,
maybe better flow control analysis. Therefore, the warning should
eventually be enabled only for modernish gccs (what about clang and
Intel cc?)
|
|
|
|
|
|
|
| |
This reverts commit 8c2b19724d117cecfa186d044abdbf766372c679.
I don't understand - smoke-me came back happy with three
separate reports... oh well, some other time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- after croak/die/exit (or return), break (or return!) are pointless
(break is not a terminator/separator, it's a promise of a jump)
- after goto, another goto (!) is pointless
- in some cases (usually function ends) introduce explicit NOT_REACHED
to make the noreturn nature clearer (do not do this everywhere, though,
since that would mean adding NOT_REACHED after every croak)
- for the added NOT_REACHED also add /* NOTREACHED */ since
NOT_REACHED is for gcc (and VC), while the comment is for linters
- declaring variables in switch blocks is just too fragile:
it kind of works for narrowing the scope (which is nice),
but breaks the moment there are initializations for the variables
(they will be skipped!); in some easy cases simply hoist the declarations
out of the block and move them earlier
There are still a few places left.
|
|
|
|
|
|
| |
MAD = Misc Attribute Decoration; unmaintained attempt at preserving
the Perl parse tree more faithfully so that automatic conversion to
Perl 6 would have been easier.
|
|
|
|
|
| |
The dual-life dist affected uses Devel::PPPort, so can safely use
sv_catpvs() even though it wasn't added until Perl v5.8.9.
|