| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
glob() does not return a list on VMS, so joining its result fails
expectations for this test.
|
|
|
|
|
|
|
|
|
|
|
|
| |
$ ./perl -Ilib -Xe 'goto foo; glob do { foo: $1}'
Can't "goto" into a binary or list expression at -e line 1.
What binary or list expression? True, glob has the *precedence* of a list operator, but so does not:
$ ./perl -Ilib -Xe 'goto foo; not do { foo: $1}; prt "ok\n"'
ok
Glob seems to be the only exception, due to its ‘special’ op tree.
|
|
|
|
|
| |
This particular case does not risk any stack corruption, and there is
a CPAN module depending on it working (PerlX::AsyncAwait).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When goto looks for a label, it builds up a list of ops to enter. But
it begins its search a little too far out relative to the ‘goto’.
Hence, the first op gets skipped.
In 6d90e983841, I forbade same cases of inward goto-into-expression to
avoid stack corruption and crashes. I did this by pushing a marker
on to the list of ops to enter, indicating that an error should be
thrown instead.
Because goto starts the search too far up the context stack, it would
sometimes end up looking inside an expression, which would cause the
first op on the entry list to be such a marker, meaning that the next
item, which should have been skipped, would not be.
That could really screw up the context stack for cases like:
my $e = eval { goto label; label: }
because the entry list would be:
<croak-marker> entertry
instead of the previous:
entertry
Hence, entertry (which enters eval{}) would be executed from *within*
the eval, causing the exit of the eval to leave an eval on the context
stack. Crashes ensued.
This commit fixes it by checking whether we have moved past the begin-
ning of the list of entry ops before pushing a croak-marker on to it.
Goto’s implementation is really complex, and always has been. It
could be greatly simplified now thot ops have parent pointers. But
that should wait for another developement cycle.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit in general forbids entry into the parameter of a binary or
list operator, to avoid crashes and stack corruption.
In cases like
goto f;
push @array, do { f: }
and
goto f;
$a + do { f: };
it’s not possible to fix this in general. Cases like
goto f;
do { f: } + $a;
(jumping into the first parameter) have never caused problems, but I
went ahead and forbad that usage too, since it would be too compli-
cated to figure out exactly which parameter is being jumped into.
(It’s not impossible; it would just double the amount of code used to
find labels.)
List operators taking just a simple list, such as die(), have never
worked properly, because goto() bypasses the pushmark. They could be
made to work, but that would require extra work to distinguish cases
like push and print that have a first operand (sometimes implicit for
print) of a specific type. I figured it was easier just to forbid
jumping into any list operator. It’s also much easier to document.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
require calls now require ./ to be prepended to the file since . is no
longer guaranteed to be in @INC.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use set_up_inc when require.pl is loaded
move plan outside of BEGIN block
when no tests are run at BEGIN time.
Using set_up_inc allow to run these tests under minitest
but also compile them using B::C.
This also has the advantage to use a single
control point for @INC setup.
Note: some tests cannot use 'require test.pl',
unshfit is then used for them.
|
|
|
|
|
| |
Some of this is ugly, but that’s because I wrote a one-liner to do
it. It’s good enough for practical purposes.
|
|
|
|
|
| |
This code SEGVed in a cpan/ module while I was messing with pp_goto.
Add it to t/op/goto.t so that it can SEGV there instead.
|
|
|
|
|
|
|
|
|
| |
pp_goto does a LEAVE, then checks that the new CV hasn't been undefed
by the LEAVE. If it has, it croaks.
Move the decrementing of the old CV's ref count and depth to *after*
this check, since the POPSUB done during the croak unwind will do the
decrement also. Otherwise the old sub will be doubly freed.
|
|
|
|
|
|
|
|
|
|
|
| |
An obscure bug involving goto within the same scope in the presence of
compile-time optimised away blocks was introduced in Aug 2010 by commit
ac56e7de46621c6f, "Peephole optimise adjacent pairs of nextstate ops."
The bug was fixed in Oct 2014 by commit f5b5c2a37af87535, "Simplify
double-nextstate optimisation"
Add a test, to ensure that we don't regress.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Commit 049bd5ffd62b fixed problems with the wrong @_ being visible
after *_ modification followed by goto. In so doing, it made it
possible for a null to be placed at the start of the target sub’s
pad, because it was not checking that the array it got from PL_defgv
was actually non-null. Simply adding the check makes everything work.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
$ perl -e 'undef *_; &Internals::V'
Segmentation fault: 11
$ perl -e 'sub { undef *_; goto &Internals::V }->()'
$ perl5.18.1 -e 'sub { undef *_; goto &Internals::V }->()'
Segmentation fault: 11
The goto case is actually a regression from 5.16 (049bd5ffd62), as
goto used to ignore changes to *_. (Fixing one bug uncovers another.)
We shouldn’t assume that GvAV(PL_defgv) (*_{ARRAY}) gives us anything.
While we’re at it, since we have to add extra checks anyway, use them
to speed up empty @_ in goto (by checking items, rather than arg).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before ce0d59f:
$ perl -e '++$#_; &utf8::encode'
Modification of a read-only value attempted at -e line 1.
As of ce0d59f:
$ ./perl -Ilib -e '++$#_; &utf8::encode'
Assertion failed: (sv), function Perl_sv_utf8_encode, file sv.c, line 3581.
Abort trap: 6
Calling sub { utf8::encode($_[0]) } should be more or less equivalent
to calling utf8::encode, but it is not in this case:
$ ./perl -Ilib -we '++$#_; &{sub { utf8::encode($_[0]) }}'
Use of uninitialized value in subroutine entry at -e line 1.
In the first two examples above, an implementation detail is leaking
through. What you are seeing is not the array element, but a place-
holder that indicates an element that has not been assigned to yet.
We should use defelem magic so that what the XSUB assigns to will cre-
ate an array element (as happens with utf8::encode($_[0])).
All of the above applies to goto &xsub as well.
|
|
|
|
|
| |
Focus of these descriptions: Simply enable user to more easily locate tests
in file.
|
|
|
|
|
|
| |
Deciding whether this is goto-label or goto-sub can only correctly
happen after get-magic has been invoked, as get-magic can cause the
argument to begin or cease to be a subroutine reference.
|
|
|
|
|
| |
It is a little tricky, as we have to hang on to @_ while unwinding the
effects of local @_.
|
|
|
|
|
|
|
|
| |
Since we have supported for embedded nulls in strings, we shouldn’t
be using if(*label) to see whether label has a non-zero length.
It’s probably not possible to get a null into a label, but we should
still say ‘can’t find’ rather than ‘must have’ in that case.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The logic was written in such a way that goto "" just happened to slip
past all the checks and cause pp_goto to return NULL for the next op,
which means the end of the program.
goto ${\""} dies with ‘goto must have label’, so goto ""
should as well.
This also adds other tests for that error, which was apparently
untested till now.
|
|
|
|
|
|
|
|
| |
The code that compared non UTF-8 labels neglected to check that
the label's length was equal before comparing them with a memEQ,
which lead to code that used labels with the same prefixes to fail:
./perl -Ilib -E 'CATCH: { CATCHLOOP: { last CATCH; } die }'
|
|
|
|
|
|
|
|
| |
If goto &sub triggers a destructor that undefines &sub, a
crash ensues.
This commit adds an extra check in pp_goto after the unwinding of the
previous sub’s scope.
|
|
|
|
|
|
|
|
|
| |
Commit 309aab3a made goto &foo make the lexical hints of the caller of
the sub containing the goto visible when foo is called. CORE subs
need this to function properly when ‘goneto’. But in that commit I
put the PL_curcop assignment before the recursion check, causing the
warning settings of the caller to be used, instead of those at the
goto. This commit moves the PL_curcop further down in pp_goto.
|
| |
|
|
|
|
|
| |
Liberalise label syntax a little more, by allowing multiple adjacent
labels with no intervening statements, as in "foo: bar: baz:".
|
| |
|
|
|
|
|
|
|
|
| |
Include <label> in productions before <decl> and <package_block>. This
means that labels can now appear at the beginning of all statement-like
things. There was no technical reason for the restriction of labels
to substantive statements, and that restriction in any case couldn't be
applied to PLUGSTMT-based plugged-in declarations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, in code such as
use constant DEBUG=>0;
sub GAK {
warn if DEBUG;
print "stuff\n";
}
the ops for C<warn if DEBUG;> would be folded to a null op (ex-const), but
the nextstate op would remain, resulting in a runtime op dispatch of nextstate,
nextstate, ...
The execution of a sequence of nexstate ops is indistinguishable from just the
last nextstate op, so teach the peephole optimiser to eliminate the first of a
pair of nextstate ops. (Except where the first carries a label, as labels
mustn't be eliminated by the optimiser, and label usage isn't conclusively
known at compile time.)
|
|
|
|
|
|
| |
Fix location identified by Father Chrysostomos, who also offered a patch, but
this patch is more efficient, as it avoids any allocation. Test code based on
his test example.
|
| |
|
| |
|
|
|
| |
p4raw-id: //depot/perl@34180
|
|
|
|
|
|
| |
From: "Jerry D. Hedden" <jdhedden@cpan.org>
Message-ID: <1ff86f510706290902k57b540a5n446fad22c1afdab0@mail.gmail.com>
p4raw-id: //depot/perl@31504
|
|
|
| |
p4raw-id: //depot/perl@31494
|
|
|
| |
p4raw-id: //depot/perl@26396
|
|
|
| |
p4raw-id: //depot/perl@25160
|
|
|
|
|
|
|
|
| |
eval 'goto &foo' is already banned, and the try-version usually
coredumps due to the code assuming the CxEVAL is actually a CxSUB.
Anyway exiting an eval but preserving "it's" @_ doesn't make much
sense.
p4raw-id: //depot/perl@24532
|
|
|
| |
p4raw-id: //depot/perl@24386
|
|
|
| |
p4raw-id: //depot/perl@24385
|
|
|
|
|
| |
next and redo didn't restore PL_curcop
p4raw-id: //depot/perl@24384
|
|
|
|
|
|
|
| |
Change 22373 to stop a memory leak in goto &foo intead caused
the elements of @_ to be freed too early. This revised fix
just transfers the reifiedness of the old @_ to the new @_
p4raw-id: //depot/perl@23418
|
|
|
|
|
|
| |
The code for goto &foo had local pointers to the stack that
pointed to the wrong place after a realloc.
p4raw-id: //depot/perl@23217
|
|
|
|
|
| |
Message-ID: <4118CDA4.3060700@divsol.com>
p4raw-id: //depot/perl@23213
|
|
|
|
|
| |
@_ sometimes wasn't getting created right
p4raw-id: //depot/perl@22870
|
|
|
|
|
| |
the fix having been suggested by xmath via Juerd.
p4raw-id: //depot/perl@21425
|
|
|
|
|
|
|
|
|
|
|
| |
Date: Sat, 24 May 2003 12:25:17 +0100
Message-ID: <20030524112517.GA11761@fdgroup.com>
Subject: [PATCH] Re: [perl #22299] goto doesn't find label
From: Dave Mitchell <davem@fdgroup.com>
Date: Mon, 26 May 2003 13:47:11 +0100
Message-ID: <20030526124710.GA17670@fdgroup.com>
p4raw-id: //depot/perl@19625
|
|
|
|
|
|
|
|
|
|
|
| |
Date: Thu, 22 May 2003 10:13:19 +0100
Message-ID: <20030522091319.GA4568@fdgroup.com>
Subject: Re: [PATCH #2] Re: [perl #22181] goto undefines my() variables
From: Dave Mitchell <davem@fdgroup.com>
Date: Fri, 23 May 2003 17:09:44 +0100
Message-ID: <20030523160944.GC9194@fdgroup.com>
p4raw-id: //depot/perl@19610
|