This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Karl Williamson [Tue, 14 Feb 2017 03:40:57 +0000 (20:40 -0700)]
Add test for [perl #130675]
Karl Williamson [Tue, 14 Feb 2017 03:37:47 +0000 (20:37 -0700)]
t/lib/croak/toke_l1: Cut down test
The previous commits hardening toke.c against malformed UTF-8 input have
allowed this test case to be cut down substantially
Karl Williamson [Mon, 13 Feb 2017 19:35:18 +0000 (12:35 -0700)]
toke.c: Fix bugs where UTF-8 is turned on in mid chunk
Previous commits have tightened up the checking of UTF-8 for
well-formedness in the input program or string eval. This is done in
lex_next_chunk and lex_start. But it doesn't handle the case of
use utf8; foo
because 'foo' is checked while UTF-8 is still off. This solves that
problem by noticing when utf8 is turned on, and then rechecking at the
next opportunity.
See thread beginning at
http://nntp.perl.org/group/perl.perl5.porters/242916
This fixes [perl #130675]. A test will be added in a future commit
This catches some errors earlier than they used to be and aborts. so
some tests in the suite had to be split into multiple parts.
Karl Williamson [Mon, 13 Feb 2017 19:16:45 +0000 (12:16 -0700)]
mg.c: PL_hints is unsigned
Therefore it's dangerous to presume things fit into an IV.
Karl Williamson [Mon, 13 Feb 2017 19:02:54 +0000 (12:02 -0700)]
toke.c: Add branch prediction
The input is far more likely to be well-formed than not.
Karl Williamson [Mon, 13 Feb 2017 18:54:06 +0000 (11:54 -0700)]
toke.c: Fix comments describing S_tokeq
The comments about what this function does were incorrect.
Karl Williamson [Mon, 13 Feb 2017 18:51:59 +0000 (11:51 -0700)]
toke.c: Slight refactor.
This moves an automatic variable to closer to the only place it is used;
it also adds branch prediction. It is likely that the input will be
well-formed.
Karl Williamson [Mon, 13 Feb 2017 18:29:35 +0000 (11:29 -0700)]
toke.c: White space, comments, braces
I am adding the braces because in one of the areas, the lack of braces
had led to a blead failure.
Karl Williamson [Mon, 13 Feb 2017 18:31:53 +0000 (11:31 -0700)]
toke.c: Don't compare same bytes twice
Before starting this memEQ, we know that the first bytes are the same,
so might as well start the compare with the 2nd bytes.
Karl Williamson [Mon, 13 Feb 2017 18:15:07 +0000 (11:15 -0700)]
toke.c: Move declaration
This automatic variable doesn't need such a large scope.
Karl Williamson [Thu, 9 Feb 2017 05:18:27 +0000 (22:18 -0700)]
perly.c: Clarify comment
Karl Williamson [Sat, 11 Feb 2017 04:26:55 +0000 (21:26 -0700)]
sv.h: Add comment
Sawyer X [Sun, 12 Feb 2017 10:52:12 +0000 (12:52 +0200)]
Merge branch 'sawyerx/undeprecate-backslash-c' into blead
Sawyer X [Wed, 8 Feb 2017 13:00:37 +0000 (14:00 +0100)]
Revert "Deprecating the use of C<< \cI<X> >> to specify a printable character."
This reverts commit
bfdc8cd3d5a81ab176f7d530d2e692897463c97d.
Sawyer X [Wed, 8 Feb 2017 12:34:31 +0000 (13:34 +0100)]
Revert "Avoid triggering a deprecation warnings."
This reverts commit
5ad2a0b67cdf1d90b67b991ae8708d3b9d57bad9.
We have decided to undeprecate \c. Please see:
http://www.nntp.perl.org/group/perl.perl5.porters/2017/01/msg242693.html
Karl Williamson [Sat, 11 Feb 2017 20:07:33 +0000 (13:07 -0700)]
pp_pack.c: Remove no longer relevant comment
Karl Williamson [Sat, 11 Feb 2017 20:02:46 +0000 (13:02 -0700)]
pp_pack.c: Remove needless branch
This function only sets *retlen to 0 if the input length is 0. In all
but one case, the function was not called with with that input. In that
one case, I changed to avoid calling the function with that input.
Hence we can remove checking *retlen for 0.
Karl Williamson [Sat, 11 Feb 2017 20:00:27 +0000 (13:00 -0700)]
pp_pack.c: Remove obsolete code
This code effectively reduced to
if (foo) 0 else 0
because a #define was changed to 0 some releases ago. Just replace by
0
Karl Williamson [Sat, 11 Feb 2017 19:58:16 +0000 (12:58 -0700)]
utf8.c: Move comment a few lines up in the file
Move it to where it makes more sense.
Karl Williamson [Sat, 11 Feb 2017 19:57:33 +0000 (12:57 -0700)]
utf8.h: Clarify comment
Karl Williamson [Sun, 12 Feb 2017 03:59:49 +0000 (20:59 -0700)]
utf8.h: White-space, parens only
Add parens to clarify grouping, white-space for legibility
Karl Williamson [Sun, 12 Feb 2017 03:57:36 +0000 (20:57 -0700)]
utf8.h: Add branch prediction
use bytes;
is unlikely to be the case.
Tony Cook [Sat, 11 Feb 2017 21:53:58 +0000 (08:53 +1100)]
(perl #126203) build issues
helps to test builds with the right options...
Karl Williamson [Fri, 13 Jan 2017 19:35:26 +0000 (12:35 -0700)]
Change av_foo_nomg() name
These names sparked some controversy when created:
http://www.nntp.perl.org/group/perl.perl5.porters/2016/03/msg235216.html
I looked through existing code for paradigms to follow, and found some
occurrences of 'skip_foo_mg'. So this commit changes the names to be
av_top_index_skip_len_mg()
av_tindex_skip_len_mg()
This is explicit about the type of magic that is ignored, and will still
be valid if another type of magic ever gets added.
Jarkko Hietaniemi [Sat, 11 Feb 2017 00:03:29 +0000 (19:03 -0500)]
Coverity #28930: unchecked return value
Strangely, this was apparently found already in 2014, but it now
(rightfully) showed up. Coverity database tweak?
Karl Williamson [Fri, 10 Feb 2017 17:04:16 +0000 (10:04 -0700)]
Net::Ping: Todo a test on EBCDIC
This is just to get it to pass. It appears to be a permissions problem
on our one smoker.
Jarkko Hietaniemi [Sun, 5 Feb 2017 23:50:11 +0000 (18:50 -0500)]
Coverity #155950: pRExC->code_blocks is blindly derefed
Even though code calling S_pat_upgrade_to_utf8 from the
Perl_re_op_compile is testing the code_blocks for NULLness.
Karl Williamson [Wed, 8 Feb 2017 22:48:56 +0000 (15:48 -0700)]
regcomp.c: Fix so will compile on C++11
See
147e38468b8279e26a0ca11e4efd8492016f2702 for complete explanation
Tony Cook [Thu, 9 Feb 2017 00:19:45 +0000 (11:19 +1100)]
(perl #126203) avoid potential leaks on quadmath_snprintf() failure
In the unlikely case quadmath_snprintf() fails both sv_vcatpvfn_flags()
and my_snprintf() could leak the temp format string returned by
quadmath_format_single() if quadmath_format_single() had to rebuild
the format.
Getting quadmath_snprintf() to fail in this context seems impractical,
but future changes may make it happen, so clean up after ourselves.
Neil Bowers [Sun, 5 Feb 2017 21:18:37 +0000 (21:18 +0000)]
Getopt::Std: Changed pod NAME to follow convention
See thread at http://nntp.perl.org/group/perl.perl5.porters/242374
Karl Williamson [Tue, 7 Feb 2017 17:00:19 +0000 (10:00 -0700)]
locale.c: Use only C89 legal C
An array was being declared and initialized from a non-constant.
Spotted by James Keenan
Karl Williamson [Wed, 8 Feb 2017 04:42:40 +0000 (21:42 -0700)]
Add TODO test for [perl #125493]
Tony Cook [Wed, 8 Feb 2017 03:56:10 +0000 (14:56 +1100)]
perldelta for
d6851fe9ee8e
Tony Cook [Wed, 8 Feb 2017 03:38:45 +0000 (14:38 +1100)]
(perl #130705) don't convert match with argument to qr
Code like:
0 =~ qr/1/ ~~ 0
would have the match operator replaced with qr, leaving an op tree
like:
e <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
d <@> print vK ->e
3 <0> pushmark s ->4
c <2> aelem sK/2 ->d
5 <1> rv2av[t1] sKR/1 ->6
4 <$> gv(*0) s ->5
b <2> smartmatch sK/2 ->c
9 </> qr() sKS ->a <=== umm
6 <$> const(IV 0) s ->7
8 <|> regcomp(other->9) sK ->9
7 </> qr(/"1"/) s ->8
a <$> const(IV 0) s ->b
when executed, this would leave an extra value on the stack:
$ ./perl -Dst -e 'print(0->[0 =~ qr/1/ ~~ 0])'
Smartmatch is experimental at -e line 1.
EXECUTING...
=>
(-e:0) enter
=>
(-e:0) nextstate
=>
(-e:1) pushmark
=> *
(-e:1) gv(main::0)
=> * GV()
(-e:1) rv2av
=> * AV()
(-e:1) const(IV(0))
=> * AV() IV(0)
(-e:1) qr
=> * AV() IV(0) \REGEXP()
(-e:1) regcomp
=> * AV() IV(0)
(-e:1) qr
=> * AV() IV(0) \REGEXP()
(-e:1) const(IV(0))
=> * AV() IV(0) \REGEXP() IV(0)
(-e:1) smartmatch
=> * AV() IV(0) SV_NO
(-e:1) aelem
=> * AV() SV_UNDEF <=== trying to print an AV
(-e:1) print
perl: sv.c:2941: Perl_sv_2pv_flags: Assertion `((svtype)((sv)->sv_flags & 0xff)) != SVt_PVAV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVHV && ((svtype)((sv)->sv_flags & 0xff)) != SVt_PVFM' failed.
Aborted
Pali [Sun, 18 Sep 2016 15:16:33 +0000 (17:16 +0200)]
pod: Do not suggest to use insecure :utf8 PerlIO layer when reading files
Instead use strict :encoding(UTF-8) PerlIO layer for input files.
Karl Williamson [Tue, 7 Feb 2017 23:21:25 +0000 (16:21 -0700)]
Add test for [perl #129157]
Tony Cook [Tue, 7 Feb 2017 23:16:33 +0000 (10:16 +1100)]
perldelta for
dd314e1ca8c3
Tony Cook [Tue, 7 Feb 2017 05:14:53 +0000 (16:14 +1100)]
(perl #130722) don't call SvPVX() on a glob
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.
Karl Williamson [Tue, 7 Feb 2017 20:12:36 +0000 (13:12 -0700)]
Add .t for malformed-UTF-8 toke.c testing
This adds a non-UTF-8 encoded file to make it easier to test malformed
UTF-8 strings. The file is automatically skipped on EBCDIC platforms.
The file is initialized with a test for [perl #129037], which had
already been unknowingly fixed by commit
75219bacf5aacd315b96083de24e82cd8238e99a
David Mitchell [Tue, 7 Feb 2017 15:45:14 +0000 (15:45 +0000)]
multideref: handle both OPpLVAL_INTRO,OPpDEREF
RT #130727
In a nested dereference like $a[0]{b}[1], all but the last aelem/helem
will normally have a OPpDEREF_AV/HV flag, while the last won't have a deref
but may well have OPpLVAL_INTRO, e.g.
local $a[0]{b}[1] = 1;
The code in S_maybe_multideref() which converts a chain of aelem/helem's
into a single mltideref op assumes this - in particular that an op can't
have both OPpLVAL_INTRO and OPpDEREF* at the same time. However, the
following code violates that assumption:
@{ local $a[0]{b}[1] } = 1;
In @{expr} = 1, the array is in lvalue context, which makes expr be done
in ref (autovivify) context. So the final aelem in the above expression
gets both OPpLVAL_INTRO and OPpDEREF_AV flags.
In the old days, pp_aelem (probably more by luck than design) would action
OPpLVAL_INTRO and ignore OPpDEREF_AV. This commit makes pp_multideref
behave in the same way. In particular, there's no point in autovivifying
$a[0]{b}[1] as an array ref since the local() will be undone before it
gets a change to be used.
The easiest way to achieve this is to tun off the OPpDEREF flag on the
aelem/helem op if the OPpLVAL_INTRO flag is set.
Pali [Sun, 18 Sep 2016 15:52:36 +0000 (17:52 +0200)]
perluniintro: Use uppercase UTF-8 encoding name
Reason is consistency with other documentation files.
Pali [Sun, 18 Sep 2016 15:45:57 +0000 (17:45 +0200)]
perluniintro: Fix comment, Encode::decode does not have to return string with UTF8 flag set
Pali [Sun, 18 Sep 2016 15:44:22 +0000 (17:44 +0200)]
perluniintro: Suggest to use utf8::decode() instead heavy Encode when sequence of bytes is valid UTF-8
Pali [Sun, 18 Sep 2016 15:19:59 +0000 (17:19 +0200)]
pod: Suggest to use strict :encoding(UTF-8) PerlIO layer over not strict :encoding(utf8)
For data exchange it is better to use strict UTF-8 encoding and not perl's utf8.
Hugo van der Sanden [Wed, 5 Oct 2016 01:20:26 +0000 (02:20 +0100)]
[perl #129061] CURLYX nodes can be studied more than once
study_chunk() for CURLYX is used to set flags on the linked WHILEM
node to say it is the whilem_c'th of whilem_seen. However it assumes
each CURLYX can be studied only once, which is not the case - there
are various cases such as GOSUB which call study_chunk() recursively
on already-visited parts of the program.
Storing the wrong index can cause the super-linear cache handling in
regmatch() to read/write the byte after the end of poscache.
Also reported in [perl #129281].
Tony Cook [Sun, 9 Oct 2016 23:46:46 +0000 (10:46 +1100)]
(perl #129281) test for buffer overflow issue
Hugo van der Sanden [Mon, 6 Feb 2017 11:11:11 +0000 (11:11 +0000)]
vi hints for pat.t
James E Keenan [Sun, 5 Feb 2017 23:04:36 +0000 (18:04 -0500)]
Remove extra terminating semicolon
Detected by compiling with clang under -Weverything, which includes -Wextra-semi.
Reviewed by jhedden++.
Increment $VERSION in threads.pm.
David Mitchell [Mon, 6 Feb 2017 09:20:04 +0000 (09:20 +0000)]
Perl_fbm_instr(): remove dead code.
For the case where littlestr hasn't been FBM compiled (!SvVALID()), it
can't be SvTAIL(), so there's no need for optional \n handling.
Spotted by Coverity.
Tony Cook [Mon, 6 Feb 2017 00:38:10 +0000 (11:38 +1100)]
prevent leak of class name from retrieve_hook() on an exception
If supplied with a large class name, retrieve_hook() allocates
buffer for the class name and Safefree()s it on exit path.
Unfortunately this memory leaks if load_module() (or a couple of other
code paths) throw an exception.
So use SAVEFREEPV() to release the memory instead.
==20183== 193 bytes in 1 blocks are definitely lost in loss record 4 of 6
==20183== at 0x4C28C20: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20183== by 0x55F85D: Perl_safesysmalloc (util.c:153)
==20183== by 0x6ACA046: retrieve_hook (Storable.xs:4265)
==20183== by 0x6AD6D19: retrieve (Storable.xs:6217)
==20183== by 0x6AD8144: do_retrieve (Storable.xs:6401)
==20183== by 0x6AD85B7: pretrieve (Storable.xs:6506)
==20183== by 0x6AD8E14: XS_Storable_pretrieve (Storable.xs:6718)
==20183== by 0x5C176D: Perl_pp_entersub (pp_hot.c:4227)
==20183== by 0x55E1C6: Perl_runops_debug (dump.c:2450)
==20183== by 0x461B79: S_run_body (perl.c:2528)
==20183== by 0x46115C: perl_run (perl.c:2451)
==20183== by 0x41F1CD: main (perlmain.c:123)
John Lightsey [Tue, 24 Jan 2017 16:30:18 +0000 (10:30 -0600)]
Fix stack buffer overflow in deserialization of hooks.
The use of signed lengths resulted in a stack overflow in retrieve_hook()
when a negative length was provided in the storable data.
The retrieve_blessed() codepath had a similar problem with the placement
of the trailing null byte when negative lengths were provided.
David Mitchell [Sat, 4 Feb 2017 15:54:09 +0000 (15:54 +0000)]
pp_formline: simplify growing of PL_formtarget
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.
David Mitchell [Sat, 4 Feb 2017 15:10:49 +0000 (15:10 +0000)]
buffer overrun with format and 'use bytes'
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.
Aaron Crane [Sat, 4 Feb 2017 15:28:19 +0000 (15:28 +0000)]
Fix memory leak in generating an exception message
This was my fault; oops.
Aaron Crane [Sat, 4 Feb 2017 14:56:06 +0000 (14:56 +0000)]
Fix outdated note in perldiag
As of
4fa06845e75d453a3101cff32e24c5b743f9819e, the "Odd name/value argument
for subroutine" error has been reported from the callers' perspective.
Steffen Mueller [Fri, 3 Feb 2017 08:06:41 +0000 (09:06 +0100)]
HvTOTALKEYS() takes a HV* as argument
Incidentally, it currently works on SV *'s as well because there's an
explicit cast after an SvANY. Let's not rely on that. This commit also
removes a pointless const in a cast. Again. It takes an HV * as argument.
Let's only change that if we have a strong reason to.
Karl Williamson [Wed, 1 Feb 2017 20:15:00 +0000 (13:15 -0700)]
toke.c: Remove unused param from static function
Commit
d2067945159644d284f8064efbd41024f9e8448a reverted commit
b5248d1e210c2a723adae8e9b7f5d17076647431. b5248 removed a parameter
from S_scan_ident, and changed its interior to use PL_bufend instead of
that parameter. The parameter had been used to limit how far into the
string being parsed scan_ident could look. In all calls to scan_ident
but one, the parameter was already PL_bufend. In the one call where it
wasn't, b5248 compensated by temporarily changing PL_bufend around the
call, running afoul, eventually, of the expectation that PL_bufend
points to a NUL.
I would have expected the reversion to add back both the parameter and
the uses of it, but apparently the function interior has changed enough
since the original commit, that it didn't even think there were
conflicts. As a result the parameter got added back, but not the uses
of it.
I tried both approaches to fix this:
1) to change the function to use the parameter;
2) to simply delete the parameter.
Only the latter passed the test suite without error.
I then tried to understand why the parameter in the first place, and why
the kludge introduced by b5248 to work around removing it. It appears
to me that this is for the benefit of the intuit_more function to enable
it to discern $] from a $ ending a bracketed character class, by ending
the scan before the ']' when in a pattern.
The trouble is that modern scan_ident versions do not view themselves as
constrained by PL_bufend. If that is reached at a point where white
space is allowed, it will try appending the next input line and
continuing, thus changing PL_bufend. Thus the kludge in b5248 wouldn't
necessarily do the expected limiting anyway. The reason the approach
"1)" I tried didn't work was that the function continued to use the
original value, even after it had read in new things, instead of
accounting for those.
Hence approach "2)" is used. I'm a little nervous about this, as it may
lead to intuit_more() (which uses heuristics) having more cases where it
makes the wrong choice about $] vs [...$]. But I don't see a way around
this, and the pre-existing code could fail anyway.
Spotted by Dave Mitchell.
Karl Williamson [Tue, 31 Jan 2017 22:17:56 +0000 (15:17 -0700)]
t/lib/warnings/toke: Fix comment typos
David Mitchell [Wed, 1 Feb 2017 15:50:14 +0000 (15:50 +0000)]
avoid double-freeing regex code blocks
RT #130650 heap-use-after-free in S_free_codeblocks
When compiling qr/(?{...})/, a reg_code_blocks structure is allocated
and various SVs are attached to it. Initially this is set to be freed
via a destructor on the savestack, in case of early dying. Later the
structure is attached to the compiling regex, and a boolean flag in the
structure, 'attached', is set to true to show that the destructor no
longer needs to free the struct.
However, it is possible to get three orders of destruction:
1) allocate, push destructor, die early
2) allocate, push destructor, attach to regex, die
2) allocate, push destructor, attach to regex, succeed
In 2, the regex is freed (via the savestack) before the destructor is
called. In 3, the destructor is called, then later the regex is freed.
It turns out perl can't currently handle case 2:
qr'(?{})\6'
Fix this by turning the 'attached' boolean field into an integer refcount,
then keep a count of whether the struct is referenced from the savestack
and/or the regex. Since it normally has a value of 1 or 2, it's similar
to a boolean flag, but crucially it no longer just indicates that the
regex has a pointer to it ('attached'), but that at least one of the
savestack and regex have a pointer to it. So order of freeing no longer
matters.
I also updated S_free_codeblocks() so that it nulls out SV pointers in
the reg_code_blocks struct before freeing them. This is is generally good
practice to avoid double frees, although is probably not needed at the
moment.
Tony Cook [Wed, 1 Feb 2017 03:34:16 +0000 (14:34 +1100)]
(perl #130684) allocate enough space for the extra 'x'
77c8f26370dcc0e added support for a doubled x regexp flags, and ensured
the doubled flag was passed to the qr// created by
S_compile_runtime_code().
Unfortunately it didn't ensure enough space was allocated for that
extra 'x'.
Karl Williamson [Tue, 31 Jan 2017 21:17:14 +0000 (14:17 -0700)]
PATCH: [perl #130655] Unrecognized UTF-8 char
The root cause of this was code like this
if (a)
b
which got changed into
if (a)
c
b
thus causing 'b' to being changed to be executed unconditionally. The
solution is just to add braces
if (a) {
c
b
}
This is why I always use braces even if not required at the moment. It
was the coding standard at $work.
It turns out that #130567 doesn't even come up with this fix in place.
Karl Williamson [Tue, 31 Jan 2017 18:15:08 +0000 (11:15 -0700)]
PATCH: [perl #130656] tr// failue with UTF-8 across lines
This bug happend under things like
tr/\x{101}-\x{200}/
\x{201}-\x{301}/
The newline in the middle was crucial. As a result the second line got
parsed already knowing that the result was UTF-8, and as a result
setting a variable got skipped which happens only when we discover we
need to flip into UTF-8.
The solution adopted here is to set the variable under other conditions,
which leads to it getting set multiple times. But this extra branch and
setting is confined to somehwat rare circumstances, leaving the mainline
code untouched.
David Mitchell [Mon, 30 Jan 2017 12:25:55 +0000 (12:25 +0000)]
signature sub (\x80 triggered an assertion
RT #130661
In the presence of 'use feature "signatures"', a char >= 0x80 where a sigil
was expected triggered an assert failure, because the (signed) character
was being was being promoted to int and ended up getting returned from
yylex() as a negative value.
Karl Williamson [Mon, 30 Jan 2017 03:59:44 +0000 (20:59 -0700)]
Add test for [perl #129036]
This was fixed by
6cdc5cd8f36f88172b0fcefdcadec75f5b6600b2
(but I didn't check that this was the actual commit).
Karl Williamson [Sun, 29 Jan 2017 22:56:20 +0000 (15:56 -0700)]
PATCH: [perl #130666]: Revert "toke.c, S_scan_ident(): Don't take a "end of buffer" argument, use PL_bufend"
This reverts commit
b5248d1e210c2a723adae8e9b7f5d17076647431.
This commit, dating from 2013, was made unnecessary by later removal of
the MAD code. It temporarily changed the PL_bufend variable; doing that
ran afoul of an assertion, added in
fac0f7a38edc4e50a7250b738699165079b852d8, that expects PL_bufend to
point to a terminating NUL.
Beyond the reversion, a test is added here.
Hugo van der Sanden [Sun, 29 Jan 2017 15:10:02 +0000 (15:10 +0000)]
mention PASS2 in reginsert() example
As per
bb78386f13.
Yves Orton [Sat, 28 Jan 2017 15:20:35 +0000 (16:20 +0100)]
assert that the RExC_recurse data structure points at a valid GOSUB
This assert will fail if someone adds code that optimises away a GOSUB
call. At which point they will see the comment and know what to do.
Yves Orton [Sat, 28 Jan 2017 14:13:17 +0000 (15:13 +0100)]
silence warnings from tests about impossible quantifiers
thanks to Dave M for noticing....
Zefram [Sat, 28 Jan 2017 06:25:28 +0000 (06:25 +0000)]
in dump_sub() handle CV ref used as GV
dump_sub() can receive a CV ref where it's expecting a GV. Make it
handle that cleanly. Fixes [perl #129126].
Zefram [Sat, 28 Jan 2017 05:51:00 +0000 (05:51 +0000)]
croak on sv_setpvn() on a glob
A real glob cannot be written to as a string scalar, and a sv_setpvn()
call attempting to do so used to hit an assertion. (sv_force_normal()
coerces glob copies to strings, but leaves real globs unchanged.)
This isn't exposed through assignment ops, which have special semantics
for assignments to globs, but it can be reached through XS subs that
mutate arguments, and through "^" formats. Change sv_setpvn() to check
for globs and croak cleanly. Fixes [perl #129147].
Yves Orton [Fri, 27 Jan 2017 15:57:40 +0000 (16:57 +0100)]
only mess with NEXT_OFF() when we are in PASS2
In
31fc93954d1f379c7a49889d91436ce99818e1f6 I added code that would modify
NEXT_OFF() when we were not in PASS2, when we should not do so. Strangly this
did not segfault when I tested, but this fix is required.
Steffen Mueller [Fri, 27 Jan 2017 14:55:51 +0000 (15:55 +0100)]
Reuse previously-computed flag
Yves Orton [Fri, 27 Jan 2017 09:23:05 +0000 (10:23 +0100)]
add some details to the docs for S_reginsert()
Had these docs been here I would have saved some time debugging. So
save the next guy from the same trouble... (with my memory *I* might
even be the /next guy/. Sigh.)
Yves Orton [Fri, 27 Jan 2017 09:18:51 +0000 (10:18 +0100)]
fix RT #130561 - recursion and optimising away impossible quantifiers are not friends
Instead of optimising away impossible quantifiers like (foo){1,0} treat them
as unquantified, and guard them with an OPFAIL. Thus /(foo){1,0}/ is treated
the same as /(*FAIL)(foo)/ this is important in patterns like /(foo){1,0}|(?1)/
where the (?1) needs to be able to recurse into the (foo) even though the
(foo){1,0} can never match. It also resolves various issues (SEGVs) with patterns
like /((?1)){1,0}/.
This patch would have been easier if S_reginsert() documented that it is
the callers responsibility to properly set up the NEXT_OFF() of the inserted
node (if the node has a NEXT_OFF())
Yves Orton [Fri, 27 Jan 2017 07:45:04 +0000 (08:45 +0100)]
rename opnd to operand to save my sanity
Steve Hay [Fri, 27 Jan 2017 09:21:53 +0000 (09:21 +0000)]
Fix wrong skippage when using -DPERL_DEBUGGING_MSTATS but not -DDEBUGGING
Zefram [Fri, 27 Jan 2017 05:53:22 +0000 (05:53 +0000)]
fix ord of upgraded empty string
pp_ord fell foul of the new API stricture added by
d1f8d421df731c77beff3db92d27dc6ec28589f2. Change it to avoid calling
utf8n_to_uvchr() on an empty string. Fixes [perl #130545].
Zefram [Fri, 27 Jan 2017 03:55:46 +0000 (03:55 +0000)]
fix range op under aborted constant folding
When constant-folding a range/flipflop construct, the op_next threading
of peephole optimisation caused multiple ops in the construct to have
a null op_next, because the final (and top-level) op in the construct
is a null op. This meant that simple restoration of the top-level
op's op_next after execution wouldn't get it back into a fit state
to be composed with other ops. In the event that the range construct
couldn't be constant-folded this made it compile to a broken optree.
If it couldn't be constant-folded but could actually be executed, for
example because it generated a warning, this meant the brokenness would
be encountered at runtime. Execution would stop after the range op,
because of the null op_next.
To avoid this, temporarily mark the null op as a custom op during the
peephole optimisation that supports the execution for constant-folding.
This prevents it being op_next-threaded out, so simple op_next restoring
then works. If the constant-folding is aborted, it compiles to an
operational optree. However, the suppression of duplicate peephole
optimisation means that the null op is never ultimately threaded out
as it should be. For the time being, this stands as a cost of failed
constant-folding of range constructs.
Fixes [perl #130639].
James E Keenan [Fri, 27 Jan 2017 03:44:03 +0000 (22:44 -0500)]
Correct file mode and line lengths to keep porting tests happy.
Christian Millour [Thu, 19 Jan 2017 10:49:03 +0000 (11:49 +0100)]
document nature and use of $a and $b in sort()
Signed-off-by: Abigail <abigail@abigail.be>
Karl Williamson [Thu, 26 Jan 2017 19:29:57 +0000 (12:29 -0700)]
Test for [perl #130567]
This was omitted from
90b58c702e376ab45f13a7f10e14d8c786d05d8a.
Karl Williamson [Thu, 26 Jan 2017 05:33:22 +0000 (22:33 -0700)]
perlapi: Fix grammar
Pali [Sun, 18 Sep 2016 15:25:48 +0000 (17:25 +0200)]
pod: Suggest to use strict UTF-8 encoding when dealing with external data
For data exchange it is not good idea to use not strict perl's extended
dialect of utf8 encoding.
Pali [Sun, 18 Sep 2016 15:21:54 +0000 (17:21 +0200)]
perluniintro: Encode::encode_utf8() not always appropriate
Do not suggest to use Encode::encode_utf8() when you need to know the
byte length of a string Encode module could do some additional
operations and bytes pragma is supposed to do that job.
Karl Williamson [Thu, 26 Jan 2017 14:10:00 +0000 (07:10 -0700)]
Add Pali to AUTHORS
Chris 'BinGOs' Williams [Thu, 26 Jan 2017 11:43:35 +0000 (11:43 +0000)]
Update McUpdate
Dagfinn Ilmari Mannsåker [Thu, 26 Jan 2017 09:17:41 +0000 (09:17 +0000)]
Cherry-pick Scalar-List-Utils tainted.t fix from upstream
It's fixed properly upstream, by using $^X instead of %ENV, so use that
instead of the now-expired skip.
Dagfinn Ilmari Mannsåker [Thu, 26 Jan 2017 09:20:26 +0000 (09:20 +0000)]
Regenerate customized.dat
As of commit
254707bab3 cpan/CPAN is in sync with upstream.
Karl Williamson [Thu, 26 Jan 2017 05:34:48 +0000 (22:34 -0700)]
PATCH: [perl #130567] Assertion failure in scan_const
It turns out that eval text isn't necessarily parsed by
lex_next_chunk(), but is by lex_start(). So, add a test to there to
look for malformed UTF-8.
Karl Williamson [Thu, 26 Jan 2017 05:19:55 +0000 (22:19 -0700)]
Fix embed.fnc for utf8_to_uvchr_buf
Colin Newell [Tue, 3 Jan 2017 19:56:13 +0000 (19:56 +0000)]
Documentation patch to recommend newSVpvn over newSVpv.
(Committer made a couple of grammatical corrections)
Karl Williamson [Thu, 26 Jan 2017 04:17:09 +0000 (21:17 -0700)]
regexec.c: Clarify comment
This now explains why we allow the input pointer to go off by 1 at the
end.
Dagfinn Ilmari Mannsåker [Wed, 18 Jan 2017 12:37:26 +0000 (12:37 +0000)]
Use cBOOL() instead of ? TRUE : FALSE
Except under cpan/ and dist/
Aaron Crane [Tue, 24 Jan 2017 19:50:32 +0000 (19:50 +0000)]
RT#130623: assertions when tying into non-packages
Aaron Crane [Tue, 24 Jan 2017 18:25:37 +0000 (18:25 +0000)]
Perl_sv_dump(): allow a null-pointer argument
Since the recursive case already handles null pointers, and this function is
specifically aimed at debugging, it seems sensible to handle a null pointer
at the top level too.
David Mitchell [Tue, 24 Jan 2017 15:23:24 +0000 (15:23 +0000)]
S_do_pmop_dump_bar() reduce scope of ch variable
trivial bit of tidy-up
David Mitchell [Tue, 24 Jan 2017 14:43:05 +0000 (14:43 +0000)]
handle op_pv better in op_clear() and op_dump()
In op_clear(), the ops with labels stored in the op_pv field (OP_NEXT etc)
fall-through to the OP_TRANS/OP_TRANSR code, which determines whether to
free op_pv based on the OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF flags, which are
only valid for OP_TRANS/OP_TRANSR. At the moment the fall-through fields
don't use either of those private bits, but in case this changes in
future, only check those flag bits for trans ops.
At the same time, enhance op_dump() to display the OP_PV field of such
ops.
Also, fix a leak I introduced in the recently-added S_gv_display()
function.
David Mitchell [Tue, 24 Jan 2017 13:55:45 +0000 (13:55 +0000)]
perlapi.pod: remove AvARRAY() example from sortsv()
The docs for the Perl_sort() API function include a 1-line example
of sorting an AV in-place using AvARRAY(av). Since AvARRAY() isn't
part of the API and the example would fail on tied or magic arrays,
just delete it.
At the same time, clarify the docs a bit for Perl_sort() and
Perl_sort_flags()
David Mitchell [Sun, 30 Oct 2016 12:15:03 +0000 (12:15 +0000)]
better handle freeing of code blocks in /(?{...})/
[perl #129140] attempting double-free
Thus fixes some leaks and double frees in regexes which contain code
blocks.
During compilation, an array of struct reg_code_block's is malloced.
Initially this is just attached to the RExC_state_t struct local var in
Perl_re_op_compile(). Later it may be attached to a pattern. The difficulty
is ensuring that the array is free()d (and the ref counts contained within
decremented) should compilation croak early, while avoiding double frees
once the array has been attached to a regex.
The current mechanism of making the array the PVX of an SV is a bit flaky,
as the array can be realloced(), and code can be re-entered when utf8 is
detected mid-compilation.
This commit changes the array into separately malloced head and body.
The body contains the actual array, and can be realloced. The head
contains a pointer to the array, plus size and an 'attached' boolean.
This indicates whether the struct has been attached to a regex, and is
effectively a 1-bit ref count.
Whenever a head is allocated, SAVEDESTRUCTOR_X() is used to call
S_free_codeblocks() to free the head and body on scope exit. This function
skips the freeing if 'attached' is true, and this flag is set only at the
point where the head gets attached to the regex.
In one way this complicates the code, since the num_code_blocks field is now
not always available (it's only there is a head has been allocated), but
mainly its simplifies, since all the book-keeping is now done in the two
new static functions S_alloc_code_blocks() and S_free_codeblocks()
David Mitchell [Tue, 24 Jan 2017 11:48:00 +0000 (11:48 +0000)]
perldelta entries for op_class() and op_dump()
Entries for cd6e487 and 1e85b65