This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
7 years agoadd new release to perlhist v5.25.5
Stevan Little [Tue, 20 Sep 2016 12:59:00 +0000 (14:59 +0200)]
add new release to perlhist

7 years agofinalize the perldelta
Stevan Little [Tue, 20 Sep 2016 12:54:37 +0000 (14:54 +0200)]
finalize the perldelta

7 years agoUpdate Module::CoreList for 5.25.5
Stevan Little [Tue, 20 Sep 2016 12:34:02 +0000 (14:34 +0200)]
Update Module::CoreList for 5.25.5

7 years agoutf8.c: Fix bug in new _is_utf8_char_helper() function
Karl Williamson [Mon, 19 Sep 2016 21:37:52 +0000 (15:37 -0600)]
utf8.c: Fix bug in new _is_utf8_char_helper() function

This bug was exposed by the tests that I'm still developing

7 years agoMake regexp_nonull.t test patterns without null
Father Chrysostomos [Sun, 18 Sep 2016 19:11:28 +0000 (12:11 -0700)]
Make regexp_nonull.t test patterns without null

It was only testing matches against strings without a trailing
null byte.  Now it also tests compilation of patterns without
a trailing null byte.

7 years agoregcomp.c: S_concat_pat: guard against missing trailing nulls
Yves Orton [Sat, 17 Sep 2016 18:14:53 +0000 (20:14 +0200)]
regcomp.c: S_concat_pat: guard against missing trailing nulls

The regex engine expects the pattern to have a null byte at
SvEND(pat), but is not guaranteed to receive such a pattern
when it is called, so S_concat_pat should guard against this
case. It turns out this is only an issue when there is exactly
one "argument" to the pattern. (Consider concatenation rules, etc).

7 years agosv.c: sv_grow: newlen cannot be smaller than SvCUR()
Yves Orton [Sat, 17 Sep 2016 18:13:23 +0000 (20:13 +0200)]
sv.c: sv_grow: newlen cannot be smaller than SvCUR()

This expression dates back to about 2003 or so, and as
far as I can tell is no longer necessary.

7 years agodoop.c: use sv_setpvn() instead of sv_setpvs()
Yves Orton [Sat, 17 Sep 2016 18:12:26 +0000 (20:12 +0200)]
doop.c: use sv_setpvn() instead of sv_setpvs()

7 years agoperldelta: grammar
Lukas Mai [Mon, 19 Sep 2016 16:13:12 +0000 (18:13 +0200)]
perldelta: grammar

7 years agoCorrect one formatting error in perldelta.pod.
James E Keenan [Mon, 19 Sep 2016 12:19:38 +0000 (08:19 -0400)]
Correct one formatting error in perldelta.pod.

This was causing a failure in t/porting/podcheck.t.

7 years agoworking on perldelta some more
Stevan Little [Sun, 18 Sep 2016 21:53:27 +0000 (23:53 +0200)]
working on perldelta some more

7 years agoperldelta for e426a4af0
Father Chrysostomos [Mon, 19 Sep 2016 03:28:58 +0000 (20:28 -0700)]
perldelta for e426a4af0

7 years agoperldelta for #129287 / b43665
Father Chrysostomos [Mon, 19 Sep 2016 03:27:11 +0000 (20:27 -0700)]
perldelta for #129287 / b43665

7 years agoperldelta: Remove duplicate entry; fix typo
Father Chrysostomos [Mon, 19 Sep 2016 03:24:00 +0000 (20:24 -0700)]
perldelta: Remove duplicate entry; fix typo

I had already documented the perlinterp change.

7 years agobop.t: Delete $SIG{__WARN__}
Father Chrysostomos [Mon, 19 Sep 2016 03:20:06 +0000 (20:20 -0700)]
bop.t: Delete $SIG{__WARN__}

It is only needed for one block of tests.  Leaving the handler in
place makes it harder to add temporary diagnostics elsewhere in
the code.  (Where did my warning go?  Hey, why is ‘warn’ not work-
ing?????!!!! :-)

7 years ago[perl #129287] Make UTF8 & append null
Father Chrysostomos [Mon, 19 Sep 2016 03:17:08 +0000 (20:17 -0700)]
[perl #129287] Make UTF8 & append null

The & and &. operators were not appending a null byte to the string
in utf8 mode.

(The internal function that they use is the same.  I used &. in the
test just because its intent is clearer.)

7 years agoregexp.t: Update comments about column 1
Father Chrysostomos [Sun, 18 Sep 2016 19:19:13 +0000 (12:19 -0700)]
regexp.t: Update comments about column 1

Years out of date!

7 years agoworking on perldelta
Stevan Little [Sun, 18 Sep 2016 15:05:01 +0000 (17:05 +0200)]
working on perldelta

7 years agoperlfunc: re-document old split() @_ side effect
Aristotle Pagaltzis [Sun, 18 Sep 2016 09:53:20 +0000 (11:53 +0200)]
perlfunc: re-document old split() @_ side effect

7 years agoperlsub: scalar split no longer clobbers @_ (RT #129297)
Lukas Mai [Sun, 18 Sep 2016 07:50:16 +0000 (09:50 +0200)]
perlsub: scalar split no longer clobbers @_ (RT #129297)

7 years agoperldelta for new Unicode-handling function.
Karl Williamson [Sun, 18 Sep 2016 03:07:29 +0000 (21:07 -0600)]
perldelta for new Unicode-handling function.

7 years agoperlapi: Clarify docs for some is_utf8_foo functions
Karl Williamson [Thu, 15 Sep 2016 01:49:52 +0000 (19:49 -0600)]
perlapi: Clarify docs for some is_utf8_foo functions

7 years agoAdd isUTF8_CHAR_flags() macro
Karl Williamson [Thu, 15 Sep 2016 00:54:23 +0000 (18:54 -0600)]
Add isUTF8_CHAR_flags() macro

This is like the previous 2 commits, but the macro takes a flags
parameter so any combination of the disallowed flags may be used.  The
others, along with the original isUTF8_CHAR(), are the most commonly
desired strictures, and use an implementation of a, hopefully, inlined
trie for speed.  This is for generality and the major portion of its
implementation isn't inlined.

7 years agoAdd macro for Unicode Corregindum #9 strict
Karl Williamson [Mon, 12 Sep 2016 22:52:41 +0000 (16:52 -0600)]
Add macro for Unicode Corregindum #9 strict

This macro follows Unicode Corrigendum #9 to allow non-character code
points.  These are still discouraged but not completely forbidden.

It's best for code that isn't intended to operate on arbitrary other
code text to use the original definition, but code that does things,
such as source code control, should change to use this definition if it
wants to be Unicode-strict.

Perl can't adopt C9 wholesale, as it might create security holes in
existing applications that rely on Perl keeping non-chars out.

7 years agoAdd macro for determining if UTF-8 is Unicode-strict
Karl Williamson [Mon, 12 Sep 2016 19:38:22 +0000 (13:38 -0600)]
Add macro for determining if UTF-8 is Unicode-strict

7 years agoperlapi: Clarify isUTF8_CHAR()
Karl Williamson [Mon, 12 Sep 2016 20:30:15 +0000 (14:30 -0600)]
perlapi: Clarify isUTF8_CHAR()

7 years agoinline.h: Add 'const's; avoid hiding outer variable
Karl Williamson [Wed, 14 Sep 2016 23:09:51 +0000 (17:09 -0600)]
inline.h: Add 'const's; avoid hiding outer variable

This changes some formal parameters to be const, and avoids reusing the
same variable name within an inner block, to avoid confusion

7 years agoAdd tests for is_valid_partial_utf8_char_flags()
Karl Williamson [Thu, 8 Sep 2016 17:34:15 +0000 (11:34 -0600)]
Add tests for is_valid_partial_utf8_char_flags()

7 years agoAdd is_utf8_valid_partial_char_flags()
Karl Williamson [Mon, 12 Sep 2016 04:18:57 +0000 (22:18 -0600)]
Add is_utf8_valid_partial_char_flags()

This is a generalization of is_utf8_valid_partial_char to allow the
caller to automatically exclude things such as surrogates.

7 years agoperlapi: Reword description of is_utf8_valid_partial_char
Karl Williamson [Sun, 11 Sep 2016 15:40:37 +0000 (09:40 -0600)]
perlapi: Reword description of is_utf8_valid_partial_char

7 years agoFix off-by-one error in is_utf8_valid_partial_char()
Karl Williamson [Sun, 11 Sep 2016 04:27:37 +0000 (22:27 -0600)]
Fix off-by-one error in is_utf8_valid_partial_char()

7 years agohandy.h: Comment memEQs and memNEs
Karl Williamson [Sun, 11 Sep 2016 04:24:48 +0000 (22:24 -0600)]
handy.h: Comment memEQs and memNEs

7 years agoutf8.c: Add some UNLIKELYs
Karl Williamson [Sun, 11 Sep 2016 04:18:59 +0000 (22:18 -0600)]
utf8.c: Add some UNLIKELYs

7 years agoutf8.h: Add comment, white-space changes
Karl Williamson [Sun, 11 Sep 2016 04:18:16 +0000 (22:18 -0600)]
utf8.h: Add comment, white-space changes

7 years agoEnhance and rename is_utf8_char_slow()
Karl Williamson [Sun, 11 Sep 2016 04:09:44 +0000 (22:09 -0600)]
Enhance and rename is_utf8_char_slow()

This changes the name of this helper function and adds a parameter and
functionality to allow it to exclude problematic classes of code
points, the same ones excludeable by utf8n_to_uvchar(), like surrogates
or non-character code points.

7 years agoAPItest/t/utf8.t: Add tests
Karl Williamson [Thu, 8 Sep 2016 04:22:01 +0000 (22:22 -0600)]
APItest/t/utf8.t: Add tests

These fill in gaps in current testing.  In particular all the overlong
UTF-8 possible edge cases are now tested.

7 years agoAPItest/utf8.t: Some clean up
Karl Williamson [Thu, 8 Sep 2016 04:14:38 +0000 (22:14 -0600)]
APItest/utf8.t: Some clean up

This adds some information to test names, does some white-space
alignments, changes one test to stress things slightly more, and adds a
'use bytes' because in some cases the desired byte-oriented output was
not showing up.

7 years agoTest isUTF8_CHAR()
Karl Williamson [Mon, 5 Sep 2016 03:32:08 +0000 (21:32 -0600)]
Test isUTF8_CHAR()

7 years agolib/warnings/utf8: Reinstate warning test
Karl Williamson [Sun, 11 Sep 2016 04:19:42 +0000 (22:19 -0600)]
lib/warnings/utf8: Reinstate warning test

I removed this in 35f8c9bd0ff4f298f8bc09ae9848a14a9667a95a, thinking the
warning was no longer being raised.  But in fact, it was showing a bug,
now fixed by the previous commit.

7 years agoRevamp overlong handling in is_utf8_char_slow, fixing a bug
Karl Williamson [Sun, 11 Sep 2016 03:15:04 +0000 (21:15 -0600)]
Revamp overlong handling in is_utf8_char_slow, fixing a bug

This combines EBCDIC and ASCII branches as much as possible, and fixes a
bug that showed up only on EBCDIC platforms, and 64-bit ASCII ones for
the highest overlong, where it could erroneously conclude that a
sequence was an overlong.

Tests are coming in a future commit.
.

7 years agoutf8.c: Fix typo in comment, add some comments
Karl Williamson [Sun, 11 Sep 2016 03:06:39 +0000 (21:06 -0600)]
utf8.c: Fix typo in comment, add some comments

7 years agoutf8.c: Extract duplicate code to common fcn
Karl Williamson [Sat, 10 Sep 2016 15:00:03 +0000 (09:00 -0600)]
utf8.c: Extract duplicate code to common fcn

Actually the code isn't quite duplicate, but should be because one
instance is wrong.  This failure would only show up on EBCDIC platforms.
Tests are coming in a future commit.

7 years agohandy.h: Add memLT, memLE, memGT, memGE
Karl Williamson [Sat, 10 Sep 2016 14:54:36 +0000 (08:54 -0600)]
handy.h: Add memLT, memLE, memGT, memGE

These correspond to strLT, etc.  I am deferring documenting them in case
this turns out to be a bad idea for some reason.

7 years agoUnconditionally define memcmp() if not sane
Karl Williamson [Sat, 10 Sep 2016 14:46:18 +0000 (08:46 -0600)]
Unconditionally define memcmp() if not sane

Prior to this commit, if there was a #define for memcmp that invoked a
version that Configure deemed to not be sufficient for normal use, it
was retained, so that perl used the defective version.  This apparently
hasn't been a problem in the field, but I realized the potential issue
doing code reading, and am correcting it.

7 years agoisUTF8_CHAR(): Bring UTF-EBCDIC to parity with ASCII
Karl Williamson [Sat, 3 Sep 2016 20:12:27 +0000 (14:12 -0600)]
isUTF8_CHAR(): Bring UTF-EBCDIC to parity with ASCII

This changes the macro isUTF8_CHAR to have the same number of code
points built-in for EBCDIC as ASCII.  This obsoletes the
IS_UTF8_CHAR_FAST macro, which is removed.

Previously, the code generated by regen/regcharclass.pl for ASCII
platforms was hand copied into utf8.h, and LIKELY's manually added, then
the generating code was commented out.  Now this has been done with
EBCDIC platforms as well.  This makes regenerating regcharclass.h
faster.

The copied macro in utf8.h is moved by this commit to within the main
code section for non-EBCDIC compiles, cutting the number of #ifdef's
down, and the comments about it are changed somewhat.

7 years agoregen/regcharclass.pl: surrogates are code points
Karl Williamson [Sat, 3 Sep 2016 18:15:29 +0000 (12:15 -0600)]
regen/regcharclass.pl: surrogates are code points

They are not "characters"

7 years agoAdd IS_UTF8_INVARIANT and IS_UVCHR_INVARIANT to API
Karl Williamson [Sat, 3 Sep 2016 22:13:15 +0000 (16:13 -0600)]
Add IS_UTF8_INVARIANT and IS_UVCHR_INVARIANT to API

7 years agoutfebcdic.h: Fix typo in comment
Karl Williamson [Thu, 8 Sep 2016 04:03:21 +0000 (22:03 -0600)]
utfebcdic.h: Fix typo in comment

7 years agoAdd #defines for XS code for Unicode Corregindum 9
Karl Williamson [Wed, 14 Sep 2016 22:05:35 +0000 (16:05 -0600)]
Add #defines for XS code for Unicode Corregindum 9

These are convenience macros.

7 years agoperlapi: Clarify utf8n_to_uvchr entry
Karl Williamson [Wed, 14 Sep 2016 22:02:50 +0000 (16:02 -0600)]
perlapi: Clarify utf8n_to_uvchr entry

7 years agoperlunicode: Fix typo
Karl Williamson [Wed, 14 Sep 2016 21:57:34 +0000 (15:57 -0600)]
perlunicode: Fix typo

7 years agoappend_utf8_from_native_byte: Add parens for clarity
Karl Williamson [Tue, 13 Sep 2016 22:40:44 +0000 (16:40 -0600)]
append_utf8_from_native_byte: Add parens for clarity

I can never remember the precedence of dereference and ++.

7 years agoFix English in perlfunc
E. Choroba [Sat, 17 Sep 2016 20:05:15 +0000 (22:05 +0200)]
Fix English in perlfunc

7 years agoAdd regexp_nonull.t
Father Chrysostomos [Sat, 17 Sep 2016 18:06:55 +0000 (11:06 -0700)]
Add regexp_nonull.t

for testing the regular expression engine with strings that
lack a trailing null byte.

7 years agoNested single quotes in documentation example
E. Choroba [Fri, 16 Sep 2016 08:33:53 +0000 (01:33 -0700)]
Nested single quotes in documentation example

Documentation of the Unicode Bug contains an example that nests single
quotes in a shell. Most shells can't do that. Patch attached.

Signed-off-by: Abigail <abigail@abigail.be>
7 years agorestore comment mangled by 27da23d53ccce6
Lukas Mai [Fri, 16 Sep 2016 11:02:16 +0000 (13:02 +0200)]
restore comment mangled by 27da23d53ccce6

7 years agoPaying respect to Jon AVENJ Portnoy
Sawyer X [Wed, 14 Sep 2016 21:29:46 +0000 (23:29 +0200)]
Paying respect to Jon AVENJ Portnoy

7 years agoUpgrade Test::Simple from version 1.302052 to 1.302056
Steve Hay [Wed, 14 Sep 2016 13:08:37 +0000 (14:08 +0100)]
Upgrade Test::Simple from version 1.302052 to 1.302056

7 years agoIncrease $XS::APItest::VERSION to 0.84
Father Chrysostomos [Wed, 14 Sep 2016 06:05:43 +0000 (23:05 -0700)]
Increase $XS::APItest::VERSION to 0.84

7 years agoperldelta for #129164 / 92b69f650
Father Chrysostomos [Wed, 14 Sep 2016 06:01:58 +0000 (23:01 -0700)]
perldelta for #129164 / 92b69f650

7 years agoperldelta for #129090 / 6da13066b6
Father Chrysostomos [Wed, 14 Sep 2016 06:00:56 +0000 (23:00 -0700)]
perldelta for #129090 / 6da13066b6

7 years agoperldelta for #47047 / 1de22db27a
Father Chrysostomos [Wed, 14 Sep 2016 05:59:18 +0000 (22:59 -0700)]
perldelta for #47047 / 1de22db27a

7 years agoperldelta for #129196 / 9bde56224
Father Chrysostomos [Wed, 14 Sep 2016 05:57:22 +0000 (22:57 -0700)]
perldelta for #129196 / 9bde56224

7 years agoperldelta for ba0a4150f
Father Chrysostomos [Wed, 14 Sep 2016 05:54:49 +0000 (22:54 -0700)]
perldelta for ba0a4150f

7 years agoperldelta for #125679 / 2b6a5bfb1
Father Chrysostomos [Wed, 14 Sep 2016 05:50:30 +0000 (22:50 -0700)]
perldelta for #125679 / 2b6a5bfb1

7 years agoperldelta for #107726 / 8bc40f3a4e
Father Chrysostomos [Wed, 14 Sep 2016 05:48:29 +0000 (22:48 -0700)]
perldelta for #107726 / 8bc40f3a4e

7 years agoperldelta for 65169990
Father Chrysostomos [Wed, 14 Sep 2016 05:46:43 +0000 (22:46 -0700)]
perldelta for 65169990

7 years ago[perl #129267] Test for gv_fetchmethod buffer overrun
Father Chrysostomos [Wed, 14 Sep 2016 05:38:59 +0000 (22:38 -0700)]
[perl #129267] Test for gv_fetchmethod buffer overrun

7 years agofix #129267: rework gv_fetchmethod_pvn_flags separator parsing
Yves Orton [Tue, 13 Sep 2016 21:14:49 +0000 (23:14 +0200)]
fix #129267: rework gv_fetchmethod_pvn_flags separator parsing

With previous code we could overrun the end of the name when
the last char in the string was a colon. This reworks the code
so it is more clear what is going on, and so it more similar
to other code that also parses out package separaters in gv.c.

This is a rework of the reverted patches:
243ca72 rename "nend" name_cursor in Perl_gv_fetchmethod_pvn_flags
b053c93 fix: [perl #129267] Possible string overrun with invalid len in gv.c

7 years agoclean up gv_fetchmethod_pvn_flags: rename nsplit to last_separator
Yves Orton [Tue, 13 Sep 2016 21:10:48 +0000 (23:10 +0200)]
clean up gv_fetchmethod_pvn_flags: rename nsplit to last_separator

nsplit if set points at the first char of the last separator
in name, so rename it so it is more comprehensible what it means.

7 years agoclean up gv_fetchmethod_pvn_flags: move origname init to function start
Yves Orton [Tue, 13 Sep 2016 21:06:58 +0000 (23:06 +0200)]
clean up gv_fetchmethod_pvn_flags: move origname init to function start

so it is more obvious that it is a constant copy of the
original name.

7 years agoclean up gv_fetchmethod_pvn_flags: introduce name_end
Yves Orton [Tue, 13 Sep 2016 21:06:07 +0000 (23:06 +0200)]
clean up gv_fetchmethod_pvn_flags: introduce name_end

nend is used for too many things, this replaces various
uses of nend with name_end, which is constant.

this is a first step to fixing [perl #129267], which shouldnt
change any behavior

7 years agoRevert "fix: [perl #129267] Possible string overrun with invalid len in gv.c"
Yves Orton [Tue, 13 Sep 2016 19:53:48 +0000 (21:53 +0200)]
Revert "fix: [perl #129267] Possible string overrun with invalid len in gv.c"

This reverts commit b053c9385f29680bc812db3da64ce5c4d45d0cf7.

7 years agoRevert "rename "nend" name_cursor in Perl_gv_fetchmethod_pvn_flags"
Yves Orton [Tue, 13 Sep 2016 19:53:36 +0000 (21:53 +0200)]
Revert "rename "nend" name_cursor in Perl_gv_fetchmethod_pvn_flags"

This reverts commit 243ca72243bd234ab5ef1818a32b9c6dd68f777c.

7 years agorename "nend" name_cursor in Perl_gv_fetchmethod_pvn_flags
Yves Orton [Tue, 13 Sep 2016 19:21:08 +0000 (21:21 +0200)]
rename "nend" name_cursor in Perl_gv_fetchmethod_pvn_flags

nend is a crappy name, and we use name_cursor in other
contexts that do similar things. consistency++

7 years agofix: [perl #129267] Possible string overrun with invalid len in gv.c
Yves Orton [Tue, 13 Sep 2016 19:19:53 +0000 (21:19 +0200)]
fix: [perl #129267] Possible string overrun with invalid len in gv.c

Perl_gv_fetchmethod_pvn_flags contains various subtle logic bugs related to parsing
fully qualified method names. In particular if you feed the function a string
which ends with a single colon it will end up accessing memory past the end
of the string. In addition when checking for the second colon in a fully qualified
name we could potentially access memory we dont own, and certainly access memory
not part of the string

7 years ago[perl #129164] Crash with splice
Father Chrysostomos [Mon, 12 Sep 2016 04:29:56 +0000 (21:29 -0700)]
[perl #129164] Crash with splice

This fixes #129166 and #129167 as well.

splice needs to take into account that arrays can hold NULLs and
return &PL_sv_undef in those cases where it would have returned a
NULL element.

7 years agopad.c:pad_fixup_inner_anons: Add assertions
Father Chrysostomos [Sat, 10 Sep 2016 14:27:43 +0000 (07:27 -0700)]
pad.c:pad_fixup_inner_anons: Add assertions

These would have made it easier to track down the bug fixed by
the previous commit.

7 years ago[perl #129090] Crash with sub c{sub c}
Father Chrysostomos [Sat, 10 Sep 2016 14:24:41 +0000 (07:24 -0700)]
[perl #129090] Crash with sub c{sub c}

The crash in the bug report was caused by v5.21.7-215-g307cbb9, which
added the code in question in order to fix another crash.  It exposed
an existing problem caused by v5.21.6-386-ga70f21d.

Some background:

When parsing ‘sub c{’, perl creates a new CV.  The CV gets installed
in the symbol table when the final ‘}’ is reached.

If there is already an undefined CV at that point, it gets reused and
the contents of the new CV are transferred to the existing one.  That
means that any subs defined within now have their CvOUTSIDE pointer
pointing to a stub that is about to be freed, so pad_fix_inner_anons
gets called to update those CvOUTSIDE pointers accordingly.

Formats were not getting their CvOUTSIDE pointers updated, so commit
v5.11.2-160-g421f30e added formats to the containing sub’s pad to
allow the CvOUTSIDE fix-up to apply to them, too.

That caused a crash, as explained in the commit message for
v5.17.1-213-ge09ac07, that the cited commit fixed by putting a weak RV
in the pad, not a direct pointer to the format, and giving the format
a strong CvOUTSIDE pointer.

Problem:

Commit v5.21.6-386-ga70f21d¹ fixed a problem with named subs not cor-
rectly referencing outer state vars (because of bad CvOUTSIDE point-
ers hiding the lexical vars).  It did so by extending the mechanism
already used for formats to apply to named subs as well.

The one mistake that that commit made was to add a pad entry for the
sub even if it was just a stub declaration.  That caused a sub with a
stub declaration inside it to a loop if they have the same name:

$ ./perl -Ilib -le '%c; sub c { sub c; eval q|$x| } c'

This happens because the ‘sub c;’ inserts a stub into the symbol table
and inserts a reference to that stub also into the pad of the sub cur-
rently being compiled.  The final CvOUTSIDE fix-up sets the CvOUTSIDE
of the erstwhile stub (that has just become the newly defined sub) to
the sub itself.  (The %c in the example is necessary to vivify the
typeglob; otherwise perl will cheat and the stub declaration won’t
actually create a CV.)

In addition, a crash can occur in this one-liner (reduced from the
original bug report):

$ ./miniperl -e '$a="a$a";my sub b;%c;sub c{sub b;sub c}'

The fix-up code iterates through the pad backwards, starting from the
last entry, so the CvOUTSIDE(c) -> c loop is set up before the lexical
&b entry is encountered.  When it is encountered, CvOUTSIDE pointers
are followed to find the outer pad where b is defined, but the
PARENT_PAD_INDEX stored in the &b padname is wrong for c’s own pad,
which is what we end up looking at due to the CvOUTSIDE loop.  The
‘outer’ entry may then turn out be an RV, not a CV, or just about any-
thing.  Crashes ensue.

Another, perhaps clearer, way to make it crash is to give the lexical
sub pad entry an outer offset far beyond the end of the directly-
enclosing sub:

$ ./perl -Ilib -lE '%c; my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u); state sub b; sub c { sub b {} sub c }'
Segmentation fault: 11

Solution:

The fix is to stop package stubs from creating pad entries.

¹ Which I found by bisecting like this, in case anyone is interested:
    ../perl.git/Porting/bisect.pl --expect-fail  --start=v5.20.0 --end=v5.22.0  -e '%c; sub c{sub c}; use B; print B::svref_2object(\&c)->PADLIST->ARRAYelt(0)->ARRAYelt(1)->PV'

7 years agoop.c: Avoid string cmp when unnecessary
Father Chrysostomos [Fri, 9 Sep 2016 05:17:34 +0000 (22:17 -0700)]
op.c: Avoid string cmp when unnecessary

7 years agotoke.c: Correct comment
Father Chrysostomos [Thu, 8 Sep 2016 21:25:09 +0000 (14:25 -0700)]
toke.c: Correct comment

7 years agoSwap release managers for 5.25.6 and 5.25.7
Aaron Crane [Sat, 10 Sep 2016 09:44:34 +0000 (10:44 +0100)]
Swap release managers for 5.25.6 and 5.25.7

7 years agoForce a newline in new attrs.t test.
Craig A. Berry [Fri, 9 Sep 2016 19:05:38 +0000 (14:05 -0500)]
Force a newline in new attrs.t test.

VMS is going to give you newline at EOF willy nilly, so make it
explicit and match expectations everywhere.

7 years agoperlio.c: Fix z/OS problem
Yaroslav Kuzmin [Fri, 2 Sep 2016 20:27:21 +0000 (14:27 -0600)]
perlio.c: Fix z/OS problem

See thread starting at
<6E741FE88A7C4E428528A0AAAB94D735B65C65@DFLE10.ent.ti.com>

(The commiter made some white space changes to the patch)

7 years agoRevert "tmp fix for Bleadperl breaks Variable-Magic"
David Mitchell [Thu, 8 Sep 2016 07:55:45 +0000 (08:55 +0100)]
Revert "tmp fix for Bleadperl breaks Variable-Magic"

This reverts commit 8d168aaa014262c7f93944b76b84de99af3c5513.

Variable-Magic 0.60 has been released, so this temp workaround is
no longer required.

7 years agoAdd additional tests for DirHandle to improve coverage.
James E Keenan [Fri, 5 Aug 2016 23:13:15 +0000 (19:13 -0400)]
Add additional tests for DirHandle to improve coverage.

Add descriptions to all tests. Revise per suggestions by Tony Cook.

For: RT #128856

7 years agorename S_delimcpy() to S_delimcpy_intern()
David Mitchell [Wed, 7 Sep 2016 19:57:01 +0000 (20:57 +0100)]
rename S_delimcpy() to S_delimcpy_intern()

Its a bit confusing having both S_delimcpy() and Perl_delimcpy()
functions.

7 years agoadd some code comments for the users of delimcpy()
David Mitchell [Fri, 26 Aug 2016 11:10:58 +0000 (12:10 +0100)]
add some code comments for the users of delimcpy()

While fixing delimcpy(), I found that it wasn't always clear what its
callers did, so I've added some extra code comments.

also add a balancing '}' in a comment block to help editors that
jump between matching brackets.

7 years agoPerl_delimcpy(): handle backslash as last char
David Mitchell [Thu, 25 Aug 2016 16:48:34 +0000 (17:48 +0100)]
Perl_delimcpy(): handle backslash as last char

[perl #129064] heap-buffer-overflow S_scan_heredoc
[perl #129176] Conditional jump depends on uninitialized values in
               S_scan_heredoc

Perl_delimcpy() is supposed to copy a delimited string to another buffer;
it handles \-<delimiter> escapes, but if the backslash is the last
character in the src buffer, it could overrun the end of the buffer
slightly.

Also document a bit better what this function is supposed to do.

7 years agoperlobj: s/Deferencing/Dereferencing/
Lukas Mai [Wed, 7 Sep 2016 17:30:37 +0000 (19:30 +0200)]
perlobj: s/Deferencing/Dereferencing/

7 years agofix errror handling for ':attr(foo' with no ')'
David Mitchell [Wed, 7 Sep 2016 08:30:26 +0000 (09:30 +0100)]
fix errror handling for ':attr(foo' with no ')'

When the parameter of an attribute has no matching closing ')', there
are several issues with the way the error is handled.

First, the code currently tries to set PL_bufptr back to the position
of the opening '(' for a better error message. However, since the error
will have been discovered only at EOF after all the remaining lines have
been read and discarded, the buffer no longer contains ':attr(...'.
So the error message includes a spurious \0 followed by possibly some
random chunk of characters from the last line read in.

Worse, if the input buffer gets realloced while perl searches for the ')',
then PL_bufptr is reset to point into the freed buffer. [perl #129086].

It does yyerror() rather than croak(), so further error messages appear,
even though we're at EOF and no further parsing can occur. Similar cases
such as no matching closing string delimiter all croak instead.

It resets cop_line to zero *before* printing the error, so the line number
of the error is erroneously reported as zero.

This commit fixes all these issues by handling the error more similarly
to the way unterminated strings are handled. In particular, it no longer
tries to print out the section of src where it thinks the error is.

For comparison, running perl on this code file:

    # this is line 1
    my $x :foo(bar;
    the
    quick
    brown
    fox jumps over the lazy dog

used to output:

    Unterminated attribute parameter in attribute list at /tmp/p1 line 0, near "\0\0x jumps "
    syntax error at /tmp/p1 line 0, at EOF
    Execution of /tmp/p1 aborted due to compilation errors.

but now outputs:

    Unterminated attribute parameter in attribute list at /tmp/p1 line 2.

Note how previously: the error message included two literal null chars
(represented by \0 above), followed by a random chunk of the last line;
it claimed to be on line 0; it output two further error messages.

For comparison, change the ':foo' to 'q' so that its an unterminated
string, and you get (and always got):

    Can't find string terminator ")" anywhere before EOF at /tmp/p1 line 2.

7 years agoBump Locale-Codes from 3.39 to 3.40
Sullivan Beck [Thu, 1 Sep 2016 15:08:40 +0000 (11:08 -0400)]
Bump Locale-Codes from 3.39 to 3.40

7 years agoUpgrade XSLoader from version 0.22 to 0.24
Steve Hay [Wed, 7 Sep 2016 07:49:54 +0000 (08:49 +0100)]
Upgrade XSLoader from version 0.22 to 0.24

7 years agoUpgrade Sys::Syslog from version 0.34 to 0.35
Steve Hay [Wed, 7 Sep 2016 07:43:53 +0000 (08:43 +0100)]
Upgrade Sys::Syslog from version 0.34 to 0.35

This includes changes that supersede the blead customization.

7 years ago[perl #129106] Check for null PL_curcop in IN_LC()
Father Chrysostomos [Wed, 7 Sep 2016 05:11:05 +0000 (22:11 -0700)]
[perl #129106] Check for null PL_curcop in IN_LC()

or, rather, in macros that it calls.

When exiting a string eval, the current cop may be freed, so PL_curcop
gets set to null.  With the -DC option, we may end up printfing NVs
during scope exit, so the locale macros used to make sure that the
locale is sane before converting the numbers to strings need to make
sure not to read PL_curcop->cop_hints when PL_curcop is null.

This used to crash with: ./miniperl -DC -e'eval "l/A"'

I’m not sure how to write a test for this, or even whether it’s worth
writing a test for -D, which often changes behaviour depending on
porters’ whims.

7 years agofix a stupid type error
Tony Cook [Wed, 7 Sep 2016 01:16:49 +0000 (11:16 +1000)]
fix a stupid type error

7 years ago(perl #128988) preserve PL_oldoldbufptr is preserved in scan_heredoc()
Tony Cook [Mon, 22 Aug 2016 03:56:26 +0000 (13:56 +1000)]
(perl #128988) preserve PL_oldoldbufptr is preserved in scan_heredoc()

In some cases this is used in building error messages.

7 years ago(perl #128095) check pack_sockaddr_un()'s return value
Tony Cook [Mon, 15 Aug 2016 00:39:22 +0000 (10:39 +1000)]
(perl #128095) check pack_sockaddr_un()'s return value

pack_sockaddr_un() silently truncates the supplied path if it won't
fit into the sun_path member of sockaddr_un.

This may change in the future, but for now check the path in the
sockaddr matches the desired path, and skip if it doesn't.

7 years agoFix up B::Concise tests following op flag change
Father Chrysostomos [Mon, 5 Sep 2016 17:14:29 +0000 (10:14 -0700)]
Fix up B::Concise tests following op flag change

7 years ago[perl #47047] Fix erroneous AUTOLOAD warning
Father Chrysostomos [Mon, 5 Sep 2016 16:31:31 +0000 (09:31 -0700)]
[perl #47047] Fix erroneous AUTOLOAD warning

If there was a stub present in the package into which the invocant had
been blessed, then AUTOLOADing via a *method* call would warn with ‘Use
of inherited AUTOLOAD for non-method’ even if it is a method.

A recent commit stopped OPf_REF from being set on OP_ENTERSUB, so this
commit uses that flag to indicate a method call, to allow a fast run-
time check to see whether to pass the method flag to gv_autoload.