| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
RT #131098
The helpful "you may need to install" hint which 'require' sometimes
includes in its error message these days (split across multiple lines for
clarity):
$ perl -e'require Foo::Bar'
Can't locate Foo/Bar.pm in @INC
(you may need to install the Foo::Bar module)
(@INC contains: ... ) at ...
is a bit over-enthusiastic when the pathname hasn't actually been derived
from a module name:
$ perl -e'require "Foo.+/%#Bar.pm"'
Can't locate Foo.+%#Bar.pm in @INC
(you may need to install the Foo.+::%#Bar module)
(@INC contains: ... ) at ...
This commit changes things so that the hint message is only emitted if the
reverse-mapped module name is legal as a bareword:
$ perl -e'require "Foo.+/%#Bar.pm"'
Can't locate Foo.+%#Bar.pm in @INC
(@INC contains: ... ) at ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
RT #131098
5.8.0 introduced a change which as an inadvertent side-effect caused
this @INC-related require croak message:
Can't locate foo in @INC (@INC contains: ...) at ...
to be emitted even when foo is a non-searchable pathname (like /foo or
./foo) and @INC isn't used.
This commit reverts the error message in these cases to be the simple
Can't locate foo at ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
change
if (...) {
...
}
else {
if (...) {
...
}
}
to
if (...) {
...
}
else if (...) {
...
}
Should make no functional difference
|
|
|
|
|
| |
Add code more comments to S_require_file() and its helpder functions to
better understand what's going on.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The warning
do "%s" failed, '.' is no longer in @INC
was added in the previous devel release; this commit enhances it to say
do "%s" failed, '.' is no longer in @INC; did you mean do "./%s"
and updates the relevant docs.
See http://nntp.perl.org/group/perl.perl5.porters/243788.
|
|
|
|
| |
the message and warning category may need adjustment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit reverts the following (except for the additions to
t/op/write.t):
3b1d752 pp_formline(): add empty body to empty while loop
f62fd06 pp_formline(): avoid buffer overrun
90c3aa0 pp_formline: simplify growing of PL_formtarget
90c3aa0 was intended to make the code for growing the buffer simpler and
more robust with less possibility of obscure edge cases, while the
follow-up commit fixed an issue introduced by that commit, and the next
was a tweak for a compiler warning. But
http://nntp.perl.org/group/perl.perl5.porters/243101
shows that there are still issues with the new code and I've decided to
abandon the effort and leave things how they were originally - i.e.
happily working, but probably with some still undiscovered edge cases.
|
|
|
|
|
|
|
| |
my previous commit in this function added a block that happened
to follow directly after a bodiless while loop, i.e. 'while(...);'.
clang spotted this and warned. So add an empty body '{}' after the
while to visually disambiguate it.
|
|
|
|
|
|
|
|
|
|
| |
RT #130703
My recent commit v5.25.9-77-g90c3aa0 attempted to simplify buffer growth
in pp_formline(), but missed the operators which append data to
PL_formtarget *without* doing 'goto append'. These ops either append a
fieldsize's worth of bytes, or a \n (FF_NEWLINE). So grow by fieldsize
whenever we fetch something new, and for each FF_NEWLINE.
|
|
|
|
|
|
|
|
|
| |
S_doparseform() called SvPVX() on the format argument, which
produced an assertion failure when the format was supplied as a
glob.
Since S_doparseform() calls SvPV() initially and stores the result,
just use that result.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There's some reasonably complex logic to try and second guess how much
space to allocate or reallocate for the output buffer (some of which is
my doing from 2011, 26e935cfa6e7).
This commit removes most of this and now just does:
initially, grow the buffer by the size of the format. If any further
growing is needed later on (e.g. after a utf8 upgrade or due to @*) then
just grow as needed. This may give less optimal growing in edge cases
( i.e. repeated smaller grows rather than one big grow), but the old code
was often guessing wrong anyway.
This commit also makes it *always* check whether PL_formtarget needs growing
when about to append data to it, which is safer.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
RT #130703
In the scope of 'use bytes', appending a string to a format where the
format is utf8 and the string is non-utf8 but contains lots of chars
with ords >= 128, the buffer could be overrun. This is due to all the
\x80-type chars going from being stored as 1 bytes to 2 bytes, without
growing PL_formtarget accordingly.
This commit contains a minimal fix; the next commit will more generally
tidy up the grow code in pp_formline.
|
|
|
|
|
|
|
|
|
| |
A multicalled sub is reckoned to be a pseudo block, out of which it is
not permissible to goto. However, the test for a pseudo block was being
applied too early, preventing not just escape from a multicalled sub but
also a goto at the top level within the sub. This is a bug similar, but
not identical, to [perl #113938]. Now the test is deferred, permitting
goto at the sub's top level but still forbidding goto out of it.
|
|
|
|
|
|
| |
The win32 build died with the lower case versions.
Follow-up to 86191aed6f092273.
|
|
|
|
|
|
|
|
|
|
|
| |
If the format SV also appeared as an argument, and the FF_CHOP
operator modified that argument, the magic and hence the compiled
format would be freed, and the next iteration of the processing
the compiled format would read freed memory.
Unlike my original patch this copies the formsv too, since
that is also stored in the magic, and is needed for presenting
literal text from the format.
|
|
|
|
|
|
|
|
| |
This reverts commit 84b32f52b10f9912b40ef378cd0b01f4aff80630.
This reverts commit d30393aaade31b605724846a30a10dd1e96cd181.
We need more debate on this one; either we should undeprecate it,
or settle on an end-of-life version.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
RT #130188
In
sub f {
my $x = 'a';
$x =~ s/./return;/e;
}
the 'return' triggers popping any contexts above the subroutine context:
in this case, a CXt_SUBST context. In this case, Perl_dounwind() calls
cx_popblock() for the bottom-most popped context, to restore any saved
vars. However, CXt_SUBST is the one context type which *doesn't* use
'struct block' as part of its context struct union, so you can't
cx_popblock() a CXt_SUBST context.
This commit makes it skip the cx_popblock() in this case.
Bug was introduced by me with v5.23.7-235-gfc6e609.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
C++11 requires space between the end of a string literal and a macro, so
that a feature can unambiguously be added to the language. Starting in
g++ 6.2, the compiler emits a warning when there isn't a space
(presumably so that future versions can support C++11). Unfortunately
there are many such instances in the perl core. This commit fixes
those, including those in ext/, but individual commits will be used for
the other modules, those in dist/ and cpan/.
This commit also inserts space at the end of a macro before a string
literal, even though that is not deprecated, and removes useless ""
literals following a macro (instead of inserting a blank). The result
is easier to read, making the macro stand out, and be clearer as to the
intention.
Code and modules included with the Perl core need to be compilable using
C++. This is so that perl can be embedded in C++ programs. (Actually,
only the hdr files need to be so compilable, but it would be hard to
test that just the hdrs are compilable.) So we need to accommodate
changes to the C++ language.
|
|
|
|
|
|
| |
This flag was added in 5.004 and even then it didn't seem to be used for
anything. It gets set and unset in various places, but is never tested.
I'm not even sure what it was intended for.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
FC didn't like my previous patch for this issue, so here is the
one he likes better. With tests and etc. :-)
The basic problem is that code like this: /(?{ s!!! })/ can trigger
infinite recursion on the C stack (not the normal perl stack) when the
last successful pattern in scope is itself. Since the C stack overflows
this manifests as an untrappable error/segfault, which then kills perl.
We avoid the segfault by simply forbidding the use of the empty pattern
when it would resolve to the currently executing pattern.
I imagine with a bit of effort someone can trigger the original SEGV,
unlike my original fix which forbade use of the empty pattern in a
regex code block. So if someone actually reports such a bug we might
have to revert to the older approach of prohibiting this.
|
|
|
|
|
|
| |
Also remove the label/goto from CLEAR_ERRSV because labels have function
scope, which means you couldn't use CLEAR_ERRSV more than once per
function without getting a "duplicate label" error.
|
|
|
|
|
|
|
|
|
|
| |
Commit d081a35540aca5fe changed PADOFFSET (the type of op_targ) to
SSize_t (a signed type). It used to be unsigned.
pp_ctl.c: In function ‘S_doeval_compile’:
pp_ctl.c:3350:31: warning: signed and unsigned type in conditional expression [-Wsign-compare]
? oldcurcop->cop_hints : saveop->op_targ;
^
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PL_curpm provides access to the data needed to implement
the regex magic vars like $1 and $&. These vars are defined
to reference the last successfully matched pattern, or when
in regex code blocks (?{ ... }) and (??{ ... }), they
should refer to the currently executing pattern.
Unfortunately this collides with its use to implement the
empty pattern special behavior, which requires /just/
"the last successfully matched pattern" everwhere.
This meant that a pattern match like /(?{ s!!! })/ will
infinitely recurse. Fixing this would be difficult, on
the other hand detecting it is not, so we can convert
the infinite recursion/stack overflow into a normal
exception.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most ops that execute a regex, such as match and subst, are of type PMOP.
A PMOP allows the actual regex to be attached directly to that op, due
to its extra fields.
OP_SPLIT is different; it is just a plain LISTOP, but it always has an
OP_PUSHRE as its first child, which *is* a PMOP and which has the regex
attached.
At runtime, pp_pushre()'s only job is to push itself (i.e. the current
PL_op) onto the stack. Later pp_split() pops this to get access to the
regex it wants to execute.
This is a bit unpleasant, because we're pushing an OP* onto the stack,
which is supposed to be an array of SV*'s. As a bit of a hack, on
DEBUGGING builds we push a PVLV with the PL_op address embedded instead,
but this still isn't very satisfactory.
Now that regexes are first-class SVs, we could push a REGEXP onto the
stack rather than PL_op. However, there is an optimisation of @array =
split which eliminates the assign and embeds the array's GV/padix directly
in the PUSHRE op. So split still needs access to that op. But the pushre
op will always be splitop->op_first anyway, so one possibility is to just
skip executing the pushre altogether, and make pp_split just directly
access op_first instead to get the regex and @array info.
But if we're doing that, then why not just go the full hog and make
OP_SPLIT into a PMOP, and eliminate the OP_PUSHRE op entirely: with the
data that was spread across the two ops now combined into just the one
split op.
That is exactly what this commit does.
For a simple compile-time pattern like split(/foo/, $s, 1), the optree
looks like:
before:
<@> split[t2] lK
</> pushre(/"foo"/) s/RTIME
<0> padsv[$s:1,2] s
<$> const(IV 1) s
after:
</> split(/"foo"/)[t2] lK/RTIME
<0> padsv[$s:1,2] s
<$> const[IV 1] s
while for a run-time expression like split(/$pat/, $s, 1),
before:
<@> split[t3] lK
</> pushre() sK/RTIME
<|> regcomp(other->8) sK
<0> padsv[$pat:2,3] s
<0> padsv[$s:1,3] s
<$> const(IV 1)s
after:
</> split()[t3] lK/RTIME
<|> regcomp(other->8) sK
<0> padsv[$pat:2,3] s
<0> padsv[$s:1,3] s
<$> const[IV 1] s
This makes the code faster and simpler.
At the same time, two new private flags have been added for OP_SPLIT -
OPpSPLIT_ASSIGN and OPpSPLIT_LEX - which make it explicit that the
assign op has been optimised away, and if so, whether the array is
lexical.
Also, deparsing of split has been improved, to the extent that
perl TEST -deparse op/split.t
now passes.
Also, a couple of panic messages in pp_split() have been replaced with
asserts().
|
|
|
|
|
|
|
| |
For internal consistency and for consistency with other pp_leave()
functions, rename oldsp to base and mark/MARK to oldsp.
Should be no functional difference.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
g++ is too dumb to notice that in
SV *s;
if (foo)
s = ...;
...;
if (foo)
...do something with s...;
s can't be used uninitialised.
|
|
|
|
|
|
|
|
| |
This reverts commit 214949f5cdc4164f25e32c1a6ce989286456c205.
It breaks Variable::Magic.
Temporarily revert while we work out what to do.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a scope is exited normally (e.g. pp_leavetry, pp_leavesub),
we do a FREETMPS only in scalar or list context; in void context
we don't bother for efficiency reasons. Similarly, when there's an
exception and we unwind to (and then pop) an EVAL context, we haven't
been bothering to FREETMPS.
The problem with this in try/eval (exiting normally or via an exception)
is that it can delay some SVs getting freed until *after* $@ has been
set. If that freeing calls a destructor which happens to set $@,
then that overwrites the "real" value of $@.
For example
sub DESTROY { eval { die "died in DESTROY"; } }
eval { bless []; };
is ($@, "");
Before this commit, that test would fail because $@ is "died in DESTROY".
This commit ensures that leaving an eval/try by whatever means always
clears the tmps stack before setting $@.
See http://nntp.perl.org/group/perl.perl5.porters/237380.
For now, I haven't added a FREETMPS to the other pp_leavefoo()
void context cases, since I can't think of a case where it would
matter.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The error string needs to be preserved while unwinding the stacks,
but doing a simple sv_2mortal() and bumping the reference count seems
sufficient, rather than making a complete copy.
Also, avoid the mortalised SV's buffer from being stolen by using the
SV_NOSTEAL flag rather than unsetting SvTEMP.
Finally, add some basic comments above Perl_die_unwind() explaining what
it's for.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently whenever we pop an eval context used for a require, rather than
freeing the SV holding the name of the require, we just mortalise it,
since some callers of cx_popeval() need the SV to remain long enough to
use it to "undo" %INC and to croak with a message such as ""$name did not
return a true value".
Now that all those usages have been gathered into one place
(S_pop_eval_context_maybe_croak), make that function responsible for
mortalising when there's a require error, and make the general-case case
of cx_popeval() just decrement the reference count.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This function is called from 3 places in pp_ctl.c to do things on require
failure like:
delete $INC{$name};
croak "$errsv: Compilation failed in require"
After some previous commits, all 3 callers are now very similar around the
time they call this function: for example they all do
CX_LEAVE_SCOPE(cx);
cx_popeval(cx);
cx_popblock(cx);
So incorporate all that into the function too, and rename it to
S_pop_eval_context_maybe_croak() to reflect its expanded role.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is some similar code in each of these functions. Reorganise each of
those blocks to make them more similar. In particular, move some of the
EVAL context field preserving to earlier; i.e. change
CX_LEAVE_SCOPE(cx);
cx_popeval(cx);
cx_popblock(cx);
saved_foo = cx->blk_eval.foo;
to
saved_foo = cx->blk_eval.foo;
CX_LEAVE_SCOPE(cx);
cx_popeval(cx);
cx_popblock(cx);
and always examine the context entry to determine whether the EVAL is a
require, rather than using any other method (but assert they're the same);
and for leaveeval, move the CvDEPTH(evalcv)=0 setting earlier.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
After the previous commit removed some dead code, the rest of the
code can be re-arranged to be slightly tidier. In particular, this
structure:
if (foo) {
...;
}
if (in_require) {
assert(foo);
croak(...);
}
becomes the logically equivalent
if (foo) {
...;
if (in_require) {
croak(...);
}
}
assert(!in_require);
|
|
|
|
|
|
|
|
|
| |
The combination of in_require and yystatus ==3 (i.e. we caught a
JUMPENV(3)) should never happen, so remove the code that handles this
combo and replace with an assertion.
I think the dead code was wrong anyway - it re-croaked without having
first popped he current EVAL context.
|
|
|
|
|
|
|
|
| |
If something other than a plain string (e.g. a reference or typeglob)
whose stringified form contains a null character is passed to require()
or do(), it crashes, as of v5.19.3-130-gc8028aa, because the code in
question that handles the error tries to read fields of the scalar
that are only valid if it is a string internally.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
At runtime in require, validate the generated filename after translation
of '::' to '/' (and possible conversion from VMS to Unix format) to keep
the code simpler. Reject empty module names, module names starting with
'/' or '.' (ie absolute paths, hidden files, and '..'), and module names
containing NUL bytes or '/.' (ie hidden files and '..').
Add a test for Perl_load_module(), and check that it now rejects module
names which fall foul of the above rules.
Most of these can't trigger for a sinple bareword require since the
illegal module name will already have been rejected during parsing. However,
the Perl_load_module() fakes up a rquire optree including a bareword
OP_CONST, which *isn't* restricted by the lexer.
Note that this doesn't apply to non-bareword pathnames: these are both
unaffected:
require "/foo/bar.pm";
$x = "/foo/bar.pm"; require $x;
[ This is cherry-picked from a branch Nicholas wrote 4 years ago, but
which was never merged. I've kept the body of the diff the same, modulo
rebasing, but re-worded the commit title and message.
Only one test was changed: the final one in load-module.t, since a
\0 in a pathname is now trapped earlier and gives a "can't locate" error
instead. For the same reason, it also required the addition of
"no warnings 'syscalls';".
- DAPM ]
|
|
|
|
| |
Whitespace-only change.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
S_require_version() and S_require_file() do the 'require 5.010001'
and 'require Foo::Bar' actions respectively.
This makes it clear that pp_require is effectively 2 disjoint functions,
and that all the local variables previously declared at the start of
pp_require actually belong exclusively to the file loading functionality.
This is based on a patch by Nicholas from 4 years ago, except that
I did the split from scratch since pp_require has been touched quite a
bit since then.
This commit splits it in such a way that the diff is kept as small as
possible. The next commit will re-indent.
|
|
|
|
|
|
|
|
|
| |
* in pp_return(), some comments were out of date about how
leave_adjust_stacks() is called ;
* add a comment to all the functions that pp_return() tail-calls to the
effect that they can be tail-called;
* make it clearer when/why OPf_SPECIAL is set on OP_LEAVE;
* CXt_LOOP_PLAIN can be a while loop as well as a plain block.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit:
1. Renames the various dtrace probe macros into a consistent and
self-documenting pattern, e.g.
ENTRY_PROBE => PERL_DTRACE_PROBE_ENTRY
RETURN_PROBE => PERL_DTRACE_PROBE_RETURN
Since they're supposed to be defined only under PERL_CORE, this shouldn't
break anything that's not being naughty.
2. Implement the main body of these macros using a real function.
They were formerly defined along the lines of
if (PERL_SUB_ENTRY_ENABLED())
PERL_SUB_ENTRY(...);
The PERL_SUB_ENTRY() part is a macro generated by the dtrace system, which
for example on linux expands to a large bunch of assembly directives.
Replace the direct macro with a function wrapper, e.g.
if (PERL_SUB_ENTRY_ENABLED())
Perl_dtrace_probe_call(aTHX_ cv, TRUE);
This reduces to once the number of times the macro is expanded.
The new functions also take simpler args and then process the values they
need using intermediate temporary vars to avoid huge macro expansions.
For example
ENTRY_PROBE(CvNAMED(cv)
? HEK_KEY(CvNAME_HEK(cv))
: GvENAME(CvGV(cv)),
CopFILE((const COP *)CvSTART(cv)),
CopLINE((const COP *)CvSTART(cv)),
CopSTASHPV((const COP *)CvSTART(cv)));
is now
PERL_DTRACE_PROBE_ENTRY(cv);
This reduces the executable size by 1K on -O2 -Dusedtrace builds,
and by 45K on -DDEBUGGING -Dusedtrace builds.
|
|
|
|
|
|
|
|
| |
These functions don't modify the args stack, so there's no need
to dSP; ...; PUTBACK.
Also write a negated bit test condition in pp_enterwhen() a bit less
clumsily.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The value of gimme stored in the context stack is U8.
Make all other uses in the main core consistent with this.
My primary motivation on this was that the new function cx_pushblock(),
which I gave a 'U8 gimme' parameter, was generating warnings where callers
were passing I32 gimme vars to it. Rather than play whack-a-mole, it
seemed simpler to just uniformly use U8 everywhere.
Porting/bench.pl shows a consistent reduction of about 2 instructions on
the loop and sub benchmarks, so this change isn't harming performance.
|
|
|
|
| |
Replace CX_PUSHGIVEN() with cx_pushgiven() etc.
|
|
|
|
| |
Replace CX_PUSHLOOP_FOR() with cx_pushfloop_for() etc.
|