This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
4 years agot/loc_tools.pl: No setlocale when no locales
Karl Williamson [Sat, 13 Apr 2019 18:04:29 +0000 (12:04 -0600)]
t/loc_tools.pl: No setlocale when no locales

Don't call this function unconditionally.  There may be no locale
handling available, so check that first.

4 years agot/loc_tools.pl: miniperl can't use locale handling
Karl Williamson [Sat, 13 Apr 2019 18:01:40 +0000 (12:01 -0600)]
t/loc_tools.pl: miniperl can't use locale handling

Assume there is no locale handling on this system in the function
locales_enabled() if we are operating (as in minitest) without the boot
loader, as they can't be accessed because the POSIX module which
contains setlocale() can't be loaded.

4 years agot/op/magic.t: Fix skip count
Karl Williamson [Sat, 13 Apr 2019 18:01:02 +0000 (12:01 -0600)]
t/op/magic.t: Fix skip count

4 years agoReinstate and fix failing POSIX mb.t test
Karl Williamson [Fri, 12 Apr 2019 21:28:54 +0000 (15:28 -0600)]
Reinstate and fix failing POSIX mb.t test

Somehow I had pushed to blead a draft version of the test, rather than
the final one that actually should work.  The draft is what got reverted
by 8cc54175018f1cabb5c0354371c9e2ee24f8ee5a.  Reinstate the test,
corrected.

4 years agoPATCH: [perl #134004] BBC breaks Unicode::CharWidth
Karl Williamson [Fri, 12 Apr 2019 21:45:32 +0000 (15:45 -0600)]
PATCH: [perl #134004] BBC breaks Unicode::CharWidth

A user-defined property \p{IsFoo} is package specific, and can be
specified with :: package qualifiers \p{pkg1::pkg2::...::IsFoo}.  Some
other package can also define an IsFoo which is totally independent of
the first.  These properties are implemented by definining a sub IsFoo()
in the proper package.  I used cv_name() to get the fully qualified name
of the sub.  The problem with that is that it can evaluate to
pkg1::pkg2::...::_ANON_, for example.  What I really want is the
property name IsFoo, fully qualified.  This commit changes to do that.

4 years agoregcomp.c: Move code into a function
Karl Williamson [Fri, 12 Apr 2019 21:37:34 +0000 (15:37 -0600)]
regcomp.c: Move code into a function

This is in preparation for it to be called from a 2nd place

4 years agoperlfunc: Clarify
Karl Williamson [Fri, 12 Apr 2019 20:33:58 +0000 (14:33 -0600)]
perlfunc: Clarify

4 years agosv.c: Silence some warnings
Karl Williamson [Fri, 12 Apr 2019 19:15:27 +0000 (13:15 -0600)]
sv.c: Silence some warnings

This adds a cast to silence a warning.  There could be loss of data, but
this is for the 'j' flag in printf which specifies the size the output
is to be in.

4 years agoMerge branch 'warnings' into blead
Karl Williamson [Fri, 12 Apr 2019 20:04:05 +0000 (14:04 -0600)]
Merge branch 'warnings' into blead

These several commits silence warnings specific to Microsoft compilers.
They are bogus warnings as far as we can determine, but persist through
many versions of the compilers.

commit 6879a07bc8b8e75c35d0e3b765ea718cc1c7aeb2
*Author: Tomasz Konojacki <me@xenu.pl>
 Date:   Thu Apr 4 22:39:38 2019 +0200

     implement diagnostics ignore/restore macros for Visual C++

gave the easy infrastructure to turn off such warnings, but adding lines
to take advantage of this makes the code harder to read, and we came up
with alternative methods to shut the compiler up that are less
intrusive, involving casting, and subtracting from 0 instead of a unary
minus, that should be valid across platforms.

There were several other warnings I left in, because it would have
required more research than I have time for right now to be sure that
they are bogus.

4 years agopp.c: Silence some MS VC warnings
Karl Williamson [Fri, 12 Apr 2019 19:09:59 +0000 (13:09 -0600)]
pp.c: Silence some MS VC warnings

These are bogus warnings.

4 years agoregcomp.c: Silence some MS VC warnings
Karl Williamson [Fri, 12 Apr 2019 19:14:21 +0000 (13:14 -0600)]
regcomp.c: Silence some MS VC warnings

These are bogus warnings.

4 years agosv.c: Silence some MS VC warnings
Karl Williamson [Fri, 12 Apr 2019 19:13:41 +0000 (13:13 -0600)]
sv.c: Silence some MS VC warnings

These are bogus warnings.

4 years agopp_hot.c: Silence some MS VC warnings
Karl Williamson [Fri, 12 Apr 2019 19:11:45 +0000 (13:11 -0600)]
pp_hot.c: Silence some MS VC warnings

These are bogus warnings.

4 years agowarnings.t: skip some leaky tests
David Mitchell [Fri, 12 Apr 2019 15:18:57 +0000 (16:18 +0100)]
warnings.t: skip some leaky tests

A couple of tests in 7fatal leak, and thus fail, when run under Address
Sanitizer. I have a proper fix for this, but it's too close to 5.30 code
freeze to justify merging it yet. So just skip the problematic tests for
now.

4 years agofix leak in Perl_coresub_op()
David Mitchell [Fri, 12 Apr 2019 13:06:21 +0000 (14:06 +0100)]
fix leak in Perl_coresub_op()

This sub initially creates a new OP_COREARGS op to be made use of in the
various cases of a following switch statement. But in the specific case
of OP_SELECT, the op isn't actually used, and leaks. So don't allocate
it in this case.

The leak could be reproduced with the one-liner

    defined &{"CORE::select"};

and was causing t/op/coresubs.t to fail under Address Sanitiser.

4 years agoAvoid leak/crash calling CORE::foo()
David Mitchell [Tue, 9 Apr 2019 09:33:34 +0000 (10:33 +0100)]
Avoid leak/crash calling CORE::foo()

The compile time code in Perl_ck_entersub_args_core() that converts a
subroutine call like mypos(1,2) into a direct call to the built-in
function, e.g. pos(1,2), doesn't handle too many args well.
The ops associated with the extra args are excised from the op tree,
but aren't freed, and their op_sigparent pointers aren't updated
correctly.

This is noticeable if op_free() is altered to walk the tree using
op_sigparent to walk back up to the parent.

This commit frees any extra args and emits the 'Too many arguments' error
immediately, rather than tripping over later.

4 years agofix leak in do { ... } while 0
David Mitchell [Fri, 12 Apr 2019 13:52:27 +0000 (14:52 +0100)]
fix leak in do { ... } while 0

The op tree for

    do X while 0

is simplified to

    X

but the const OP for the '0' wasn't being freed and so leaked.

4 years agoPerl_newLISTOP() allocate OP_PUSHMARK safely
David Mitchell [Thu, 11 Apr 2019 16:19:31 +0000 (17:19 +0100)]
Perl_newLISTOP() allocate OP_PUSHMARK safely

This commit is a prelude to allowing op_free() to make use the parent
pointer at the end of an op_sibling chain to walk a sub-tree to be freed.

newLISTOP() converts 0..2 ops into a list, adding a new parent list op
and possibly a pushmark op. However, under Safe.pm, and specifically in
dist/Safe/t/safeops.t, allocating a pushmark can croak. If the optree
under construct at this point isn't consistent (specifically the parent
pointer not yet set), then this can crash op_free() while trying to walk
the new list to free it.

The fix is to allocate the OP_PUSHMARK if needed *before* messing with
the structure of the list sub-tree.

4 years agoRevert "ext/POSIX/t/mb.t: Add test for MB_CUR_MAX"
James E Keenan [Fri, 12 Apr 2019 12:10:46 +0000 (12:10 +0000)]
Revert "ext/POSIX/t/mb.t: Add test for MB_CUR_MAX"

This reverts commit 858fc58a344c7550c68495d7fe648b39a1a50c0c.

The unit test introduced by the commit fails on many operating systems.

Signed-off-by: James E Keenan <jkeenan@cpan.org>
4 years agowin32/Makefile: minor cleanup
Tomasz Konojacki [Tue, 9 Apr 2019 21:15:41 +0000 (23:15 +0200)]
win32/Makefile: minor cleanup

Apart from the indentation fixes, the most notable change is
replacing constructs like this one:

  !ELSE
  !IF foo
  !ENDIF
  !ENDIF

with more readable:

  !ELSEIF foo
  !ENDIF

[perl #134014]

4 years agomktables: Generalize handling of [perl #133979]
Karl Williamson [Tue, 9 Apr 2019 18:09:34 +0000 (12:09 -0600)]
mktables: Generalize handling of [perl #133979]

I realized that commit f9c1e7e9ed13a16099c8471c2030b93deb482571
works now, but future Unicode versions may add fractions that fool it.
This commit should handle any such event

4 years agoPATCH: [perl #133992] Assertion failure in scan_const
Karl Williamson [Sat, 6 Apr 2019 18:38:56 +0000 (12:38 -0600)]
PATCH: [perl #133992] Assertion failure in scan_const

I haven't done the digging, but this appears to be a failure to include
UTF-8 processing when 'use utf8' was added to Perl.

The code that was causing this in toke.c had found a qr/(?#... beginning
of comment in a pattern.  It attempted to space up to but not including
the final character, which is handled later.  (In most instances that
final character is a single-byte ')', but not in this test case.  It
spaced per-byte.  The problem is that if the final character is in UTF-8
and isn't a single byte, it leaves the input position pointing at the
final byte of that character, which creates malformed UTF-8, which the
assertion discovered.

The fix is to be cognizant that this is UTF-8 when spacing to the end,
so that the final position begins at the first byte of it.

4 years agotoke.c: Add assertion
Karl Williamson [Wed, 10 Apr 2019 18:54:30 +0000 (12:54 -0600)]
toke.c: Add assertion

4 years agotoke.c: White-space only
Karl Williamson [Sat, 6 Apr 2019 20:08:49 +0000 (14:08 -0600)]
toke.c: White-space only

This outdents code that was removed from being in a block by the
previous commit.

4 years agotoke.c: Streamline a case
Karl Williamson [Sat, 6 Apr 2019 20:05:29 +0000 (14:05 -0600)]
toke.c: Streamline a case

When we are parsing a constant, and the source and destination differ in
UTF-8ness, I realized, in single stepping through the code, that it's
simpler and more efficient to split these into two cases, rather than
try to do one case with some conditionals in the middle.

4 years agotoke.c: Change names of two variables
Karl Williamson [Sat, 6 Apr 2019 19:07:24 +0000 (13:07 -0600)]
toke.c: Change names of two variables

has_utf8 vs is_utf8.  One means the source is utf8; the other that the
dest is utf8.  But I could never remember which was which.  Change so
that is obvious

4 years agotoke.c: Use local variable instead of global
Karl Williamson [Sat, 6 Apr 2019 18:29:07 +0000 (12:29 -0600)]
toke.c: Use local variable instead of global

These two lines used a PL_ variable, whereas every other use in this
function is a local copy of it.  Change for consistency.

4 years agot/re/pat.t: Silence 'wide char' warning
Karl Williamson [Wed, 10 Apr 2019 02:34:48 +0000 (20:34 -0600)]
t/re/pat.t: Silence 'wide char' warning

This was introduced in 0a5ed81e6617c9229cc1ea042e9a70c3ec63fd65

4 years agoPATCH: [perl #133999] Assertion failure in regex match
Karl Williamson [Wed, 10 Apr 2019 02:22:34 +0000 (20:22 -0600)]
PATCH: [perl #133999] Assertion failure in regex match

This was caused by failing to limit matching to within the bounds of the
target string.  I'm pretty sure this bug has long been there, but was
exposed by the recently added wildcard property matching feature.

4 years agoPATCH: [perl #133995], Assertion failure in regmatch
Karl Williamson [Wed, 10 Apr 2019 00:53:53 +0000 (18:53 -0600)]
PATCH: [perl #133995], Assertion failure in regmatch

This was due to my forgetting that when the positive operation can only
match UTF-8 invariant characters, the complement of it can match
variants.  The only change needed is to pass the utf8ness to the macro
that does the work.

4 years agoregcomp.c: White space only
Karl Williamson [Sun, 7 Apr 2019 04:47:42 +0000 (22:47 -0600)]
regcomp.c: White space only

Indent the block newly formed in the previous commit.

4 years agoPATCH: [perl #133998] regcomp assertion failure
Karl Williamson [Sun, 7 Apr 2019 04:42:05 +0000 (22:42 -0600)]
PATCH: [perl #133998] regcomp assertion failure

This was caused in the blamed commit by me thinking I could simplify too
much.  So this commit puts back in checking specially for things like
/[\s\S]/l, which has to match every possible code point no matter what
the locale.

4 years agoAdd support for VS2019 (Visual C++ 14.2)
Steve Hay [Thu, 4 Apr 2019 17:08:52 +0000 (18:08 +0100)]
Add support for VS2019 (Visual C++ 14.2)

This also fixes LINK_FLAGS for VS2017 (Visual C++ 14.1): The subsystem
setting was missed in the changes to add VS2017 support, which was surely
just an oversight.

4 years agoext/POSIX/t/mb.t: Add test for MB_CUR_MAX
Karl Williamson [Wed, 3 Apr 2019 19:36:40 +0000 (13:36 -0600)]
ext/POSIX/t/mb.t: Add test for MB_CUR_MAX

4 years agoMake POSIX::mblen() slightly safer
Karl Williamson [Wed, 3 Apr 2019 19:17:56 +0000 (13:17 -0600)]
Make POSIX::mblen() slightly safer

by using a mutex around its call

4 years agoext/POSIX/t/mb.t: Use actual expected char len
Karl Williamson [Wed, 3 Apr 2019 18:20:08 +0000 (12:20 -0600)]
ext/POSIX/t/mb.t: Use actual expected char len

Some platforms want the precise number of expected bytes passed to
mblen(), not just some maximum.

4 years agoext/POSIX/t/mb.t: Generalize for EBCDIC
Karl Williamson [Wed, 3 Apr 2019 18:14:19 +0000 (12:14 -0600)]
ext/POSIX/t/mb.t: Generalize for EBCDIC

4 years agoPreliminary Unicode 12.1
Unicode Consortium [Tue, 2 Apr 2019 16:03:14 +0000 (10:03 -0600)]
Preliminary Unicode 12.1

4 years agoSpelling correction in documentation.
Brian Greenfield [Mon, 8 Apr 2019 13:42:30 +0000 (09:42 -0400)]
Spelling correction in documentation.

4 years agomktables: White-space only
Karl Williamson [Sun, 7 Apr 2019 00:00:58 +0000 (18:00 -0600)]
mktables: White-space only

Indent block newly formed in previous commit

4 years agoPATCH: [perl #133979] uniprops02 failing on Windows
Karl Williamson [Sat, 6 Apr 2019 23:51:13 +0000 (17:51 -0600)]
PATCH: [perl #133979] uniprops02 failing on Windows

This turns out to be because Windows doesn't necessarily round to even
on floating point %e conversions.  The solution is to add an extra entry
rounding up to odd when a fraction is precisely representable in binary.
So far, the only case where this occurs is 1/32.

4 years agoimplement diagnostics ignore/restore macros for Visual C++
Tomasz Konojacki [Thu, 4 Apr 2019 20:39:38 +0000 (22:39 +0200)]
implement diagnostics ignore/restore macros for Visual C++

4 years agoPATCH: [perl #133988], Assertion failure
Karl Williamson [Fri, 5 Apr 2019 22:34:21 +0000 (16:34 -0600)]
PATCH: [perl #133988], Assertion failure

This was due to not checking that a \N{} expanded to a single code point
in contexts where only that is legal.  This never could have worked
properly, though the assertion failure is new.

The diagnostic needs to be reworded to accommodate this new case, but
its too late in the 5.29 cycle to do that, so I'm changing just the
description, and will reword in 5.31, [perl #133996]

4 years agoPATCH: [perl #133896] Assertion failure
Karl Williamson [Fri, 5 Apr 2019 22:21:51 +0000 (16:21 -0600)]
PATCH: [perl #133896] Assertion failure

This was due to UTF8_SAFE_SKIP(s, e) not allowing s to be as large as e,
and there are legitimate cases where it can be.  This commit hardens the
macro so that it never reads above e-1, returning 0 if it otherwise
would be required to.  The assertion is changed to 's <= e'.

4 years agoregcomp.c: Change name of variable
Karl Williamson [Fri, 5 Apr 2019 22:26:36 +0000 (16:26 -0600)]
regcomp.c: Change name of variable

This better reflects its use.

4 years agoregcomp.c: Consolidate code
Karl Williamson [Fri, 5 Apr 2019 22:25:29 +0000 (16:25 -0600)]
regcomp.c: Consolidate code

This uses gotos to handle an identical panic case, instead of
duplicating the code.

4 years agoporting/diag.t: Allow nested =item's
Karl Williamson [Fri, 5 Apr 2019 23:04:38 +0000 (17:04 -0600)]
porting/diag.t: Allow nested =item's

This enhances this test to allow perldiag to have the descriptions of
error messages to contain =item lists (previously only bullet item lists
were allowed).

4 years agofix typo
Karen Etheridge [Fri, 5 Apr 2019 20:54:19 +0000 (13:54 -0700)]
fix typo

4 years ago5.28.2 should arrive this month
Steve Hay [Fri, 5 Apr 2019 20:04:52 +0000 (21:04 +0100)]
5.28.2 should arrive this month

Also: 5.29.9 was released.

4 years agoAdd epigraph for 5.28.2-RC1
Steve Hay [Fri, 5 Apr 2019 20:01:29 +0000 (21:01 +0100)]
Add epigraph for 5.28.2-RC1

4 years ago5.28.2-RC1 today
Steve Hay [Fri, 5 Apr 2019 18:34:10 +0000 (19:34 +0100)]
5.28.2-RC1 today

4 years agofixup to 'change LABEL type from pval to opval'
David Mitchell [Fri, 5 Apr 2019 16:01:53 +0000 (17:01 +0100)]
fixup to 'change LABEL type from pval to opval'

Commit v5.29.9-68-g017192018b broke g++ builds. Spotted by Karl.

4 years agoparser: change LABEL type from pval to opval
David Mitchell [Fri, 5 Apr 2019 11:49:50 +0000 (12:49 +0100)]
parser: change LABEL type from pval to opval

The items pushed onto the parser stack can be one of several types:
ival, opval, pval etc. The only remaining use of pval is when a "label:"
is encountered.

When an error occurs during parsing, ops on the parse stack get
automatically reaped these days as part of the OP slab mechanism;
but bare strings (pvals) still leak.

Convert this one remaining pval into an opval, making the toker return
an OP_CONST with an SV holding the label.

Since newSTATEOP() still expects a raw string for the label, the parser
just grabs the value returned by the toker and makes a copy of the
string from it, then immediately frees the OP_CONST and its associated
SV.

The leak was showing up in ext/XS-APItest/t/stmtasexpr.t, which expects
to parse a statement where labels are banned.

4 years agoDefine $d_has_C_UTF8 in Windows config files
Karl Williamson [Thu, 4 Apr 2019 15:12:29 +0000 (09:12 -0600)]
Define $d_has_C_UTF8 in Windows config files

Otherwise it gets an uninitialized warning.

4 years agoPartial patch for [perl #133970] Roman::Unicode broken
Karl Williamson [Thu, 4 Apr 2019 19:44:22 +0000 (13:44 -0600)]
Partial patch for [perl #133970] Roman::Unicode broken

Wrap a call out to Perl code with PUSH/POP stacks.
This gets this module working again, and maybe head off some other smoke
failures, but there are other things needed, including tests, that I'm
working on.

4 years agoRevert part of commit b6125dfcd017e2dd18dacdce91a6e071499b7aed
Steve Hay [Thu, 28 Mar 2019 22:51:09 +0000 (22:51 +0000)]
Revert part of commit b6125dfcd017e2dd18dacdce91a6e071499b7aed

4 years agomktables: Turn off DEBUG
Karl Williamson [Thu, 4 Apr 2019 18:49:41 +0000 (12:49 -0600)]
mktables: Turn off DEBUG

This inadvertently was left on, slowing down the process a little

4 years agoSilence some compiler warnings
Karl Williamson [Thu, 4 Apr 2019 03:22:29 +0000 (21:22 -0600)]
Silence some compiler warnings

Most of these are from Win32.

4 years agofix leak in Perl_vload_module()
David Mitchell [Thu, 4 Apr 2019 13:38:50 +0000 (14:38 +0100)]
fix leak in Perl_vload_module()

This function allocates a few ops, then calls Perl_utilize().
If the latter function croaks early on, those ops will be leaked,
because they won't yet have been linked into the optree.

In particular, newUNOP(OP_REQUIRE, ...) can die if passed a non-valid
module name.

This can be fixed by moving the start_subparse() call to the start of
Perl_vload_module(), before any op allocations. start_subparse() creates
a new PL_compcv, and so any ops allocated afterwards will come from that
CV's slab rather than being directly malloc()ed. On death, the CV will
be freed and its op slab will be scanned and any ops found there freed.

The leak was showing up in ext/XS-APItest/t/load-module.t under ASan.

4 years agot/charset_tools.pl: Add comments
Karl Williamson [Wed, 3 Apr 2019 18:06:47 +0000 (12:06 -0600)]
t/charset_tools.pl: Add comments

4 years agonewlocale() has a problem in openbsd
Karl Williamson [Wed, 3 Apr 2019 20:27:00 +0000 (14:27 -0600)]
newlocale() has a problem in openbsd

And therefore we can't use it, until fixed.
https://marc.info/?l=openbsd-bugs&m=155364568608759&w=2

4 years agonumeric.c: Change formal parameter to be const
Karl Williamson [Wed, 3 Apr 2019 20:31:05 +0000 (14:31 -0600)]
numeric.c: Change formal parameter to be const

as embed.fnc says it should be

4 years agoPATCH: [perl #133978] BBC breaks Jcode
Karl Williamson [Wed, 3 Apr 2019 16:25:26 +0000 (10:25 -0600)]
PATCH: [perl #133978] BBC breaks Jcode

This turned out to be caused by taking another macro as a template
without understanding the subtleties.  In this case, the variable
'previous_occurrence_end' should be updated only if 'COND' is true.  (In
the template the COND was implicitly true)

4 years agoAvoid leaks in Perl_custom_op_get_field()
David Mitchell [Wed, 3 Apr 2019 15:11:54 +0000 (16:11 +0100)]
Avoid leaks in Perl_custom_op_get_field()

In 5.14.0 a new API was introduced to register details for custom ops.
Normally the caller supplies a pointer to a static xop struct with
details for the op, which gets gets added via a hidden
    newSViv(PTR2IV(xop))
to PL_custom_ops values.

However, Perl_custom_op_get_field() also supports the older interface,
where name and desc entries were registered in PL_custom_op_names and
PL_custom_op_descs.

If it doesn't find an entry in PL_custom_ops, but does in
PL_custom_op_names, it fakes up a new-API registration in PL_custom_ops.
In this case the xop struct, and the name and description attached to it,
were leaking.

This commit fixes the leak by attaching magic to such newSViv(PTR2IV(xop))
SVs which frees the struct and strings.

4 years agofix leak in Devel-PPPort
David Mitchell [Wed, 3 Apr 2019 13:14:13 +0000 (14:14 +0100)]
fix leak in Devel-PPPort

The leaky code is only used during test. It creates 3 ops, does various
operations related to linking OpSIBLINGs, then fails to free them.

4 years agoData::Dumper - avoid leak on croak
David Mitchell [Wed, 3 Apr 2019 12:23:24 +0000 (13:23 +0100)]
Data::Dumper - avoid leak on croak

v5.21.3-742-g19be3be696 added a facility to Dumper.xs to croak if the
recursion level became too deep (1000 by default).

The trouble with this is that various parts of DD_dump() allocate
temporary SVs and buffers, which will leak if DD_dump() unceremoniously
just croaks().

This currently manifests as dist/Data-Dumper/t/recurse.t failing under
Address Sanitiser.

This commit makes the depth checking code just set a sticky 'too deep'
boolean flag, and
a) on entry, DD_dump() just returns immediately if the flag is set;
b) the flag is checked by the top-level called of DD_dump() and croaks
if set.

So the net effect is to defer croaking until the dump is complete,
and avoid any further recursion once the flag is set.

This is a bit of a quick fix. More long-term solutions would be to
convert DD_dump() to be iterative rather than recursive, and/or make
sure all temporary SVs and buffers are suitably anchored somewhere so
that they get cleaned up on croak.

4 years agoFix recent double free in S_parse_gv_stash_name()
David Mitchell [Wed, 3 Apr 2019 10:06:22 +0000 (11:06 +0100)]
Fix recent double free in S_parse_gv_stash_name()

RT #133977

My recent commit v5.29.9-29-g657ed7c1c1 moved all buffer freeing to
the end of the function, but missed removing one of the existing frees.

The problem was spotted by James E Keenan and diagnosed by Tony Cook; I just
added a test.

A simple reproducer is

my $def = defined *{"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'x"};

4 years agoCorrections to Unicode 12.0
Unicode Consortium [Tue, 2 Apr 2019 15:27:08 +0000 (09:27 -0600)]
Corrections to Unicode 12.0

Somehow I missed updating some files with the result that a few official
12.0 final corrections did not make it into
906f46d96ca4ba2d1039d576954bc5a47868348c.

These are mostly tests and break property changes for a few characters

4 years agofix locale.c under -DPERL_GLOBAL_STRUCT_PRIVATE
David Mitchell [Tue, 2 Apr 2019 09:05:37 +0000 (10:05 +0100)]
fix locale.c under -DPERL_GLOBAL_STRUCT_PRIVATE

4 years agohandy.h: Parenthesize formal parameters in macro defn
Karl Williamson [Sun, 31 Mar 2019 19:50:09 +0000 (13:50 -0600)]
handy.h: Parenthesize formal parameters in macro defn

These should be parenthesized to prevent issues when called with an
expression.

4 years agoUpdate EU::CBuilder to 0.280231
Alberto Simões [Sun, 31 Mar 2019 09:49:54 +0000 (10:49 +0100)]
Update EU::CBuilder to 0.280231

Committer: additional email address for contributor

4 years agoperldelta for 4f13e4588f9a08564a56a0d6db821f2803aed09f
James E Keenan [Sat, 30 Mar 2019 20:26:07 +0000 (16:26 -0400)]
perldelta for 4f13e4588f9a08564a56a0d6db821f2803aed09f

4 years agoquotemeta the stuff intended literally in RE
Ed J [Sat, 30 Mar 2019 19:51:53 +0000 (15:51 -0400)]
quotemeta the stuff intended literally in RE

For: RT 133966

Committer: Bump $VERSION in dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Base.pm

4 years agoregcharclass.h: Change to use new inRANGE macro
Karl Williamson [Thu, 21 Mar 2019 22:09:41 +0000 (16:09 -0600)]
regcharclass.h: Change to use new inRANGE macro

This was done by changing regen/regcharclass.pl.  This results in half
the conditionals being needed, and in some cases better error checking.

4 years agoregexec.c: Use first byte info in ANYOFH
Karl Williamson [Fri, 29 Mar 2019 18:57:40 +0000 (12:57 -0600)]
regexec.c: Use first byte info in ANYOFH

Commit 765e6ecf32a570694dcff91c1c72f98306a9390e changed ANYOFH regnodes
to note if the first byte of all code points matched is the same.  When
that is the case we can potentially speed up matching by only trying to
match at points in the input where that byte occurs.  Since ANYOFH nodes
match only UTF-8 encoded strings, that first byte is going to be a UTF-8
start byte.  If that is uncommon in the target string, this is a real
winner.

4 years agoRemove zero length valgrind files at end.
Karl Williamson [Sun, 24 Mar 2019 03:29:51 +0000 (21:29 -0600)]
Remove zero length valgrind files at end.

This resolves [perl #131135]

4 years agoregcomp.c: Use new inRANGE macro
Karl Williamson [Thu, 28 Mar 2019 03:20:58 +0000 (21:20 -0600)]
regcomp.c: Use new inRANGE macro

4 years agonumeric.c: use new inRANGE macro
Karl Williamson [Thu, 28 Mar 2019 03:19:04 +0000 (21:19 -0600)]
numeric.c: use new inRANGE macro

This commit halves the number of conditionals needed in this hot code.

4 years agohandy.h: Convert some macros to use inRANGE
Karl Williamson [Thu, 28 Mar 2019 03:12:53 +0000 (21:12 -0600)]
handy.h: Convert some macros to use inRANGE

the latter is faster, having only one conditional.

4 years agohandy.h: Comments, remove extraneous parens
Karl Williamson [Thu, 28 Mar 2019 03:09:14 +0000 (21:09 -0600)]
handy.h: Comments, remove extraneous parens

4 years agofix leak in Perl__force_out_malformed_utf8_message()
David Mitchell [Tue, 26 Mar 2019 14:58:04 +0000 (14:58 +0000)]
fix leak in Perl__force_out_malformed_utf8_message()

This function temporarily sets PL_curcop->cop_warnings to pWARN_ALL in
order to enforce mandatory warnings about malformed utf8, but it
didn't restore cop_warnings, so the old value leaked.

Can be reproduced with, e.g.

    no warnings 'utf8';
    CORE::evalbytes qq{ use utf8; "\\N{abc\x{c0}}"};

which is already exercised in t/uni/parser.t.

4 years agoPATCH: [perl #133347] Tk broken
Karl Williamson [Fri, 29 Mar 2019 00:22:11 +0000 (18:22 -0600)]
PATCH: [perl #133347] Tk broken

This was caused by utf8_to_uvchr() failing to set the returned ptr
in some circumstances, leading to reading uninitialized memory.

A test failure remains, and I'll wait for Slaven's feedback before
looking further into that.  It is in t/photo.t

 couldn't recognize image data at blib/lib/Tk/Image.pm line 21.
 # Looks like your test exited with 255 just after 100

And it's trying at that point to look at 'Xcamel.gif'

4 years agoperldiag: Rmv obsolete message
Karl Williamson [Thu, 28 Mar 2019 03:28:32 +0000 (21:28 -0600)]
perldiag: Rmv obsolete message

This restriction no longer exists, and is for an experimental feature

4 years agoPATCH: [perl #133942] BBC: BKB/Lingua-JA-Moji
Karl Williamson [Thu, 28 Mar 2019 18:26:43 +0000 (12:26 -0600)]
PATCH: [perl #133942] BBC: BKB/Lingua-JA-Moji

This ticket was originally fixed by a PR being issued on the
distribution, which was merged and a new version placed on CPAN.

But before Slaven had a chance to test it, commit
765e6ecf32a570694dcff91c1c72f98306a9390e came along, and happened to
break it again from a totally independent cause.

So we have two separate bugs on the same ticket, only one of which was
perl's fault.  And this commit fixes that.  The problematic commit was
still looking in the regnode FLAGS field in one function, whereas that
field has been repurposed for ANYOFH nodes, so should be ignored for
them.

4 years agoperlapi: Add weasel word to make stmt accurate
Karl Williamson [Sun, 24 Mar 2019 03:28:21 +0000 (21:28 -0600)]
perlapi: Add weasel word to make stmt accurate

It is possible to have a single-threaded build use the thread-safe
locale setting operations.  Add a word to indicate it's not 100% the
other way.

4 years agoPATCH: [perl #133959] Free BSD broken tests
Karl Williamson [Wed, 27 Mar 2019 16:28:21 +0000 (10:28 -0600)]
PATCH: [perl #133959] Free BSD broken tests

Commit 70bd6bc82ba64c1d197d3ec823f43c4a454b2920 fixed a leak (likely due
to a bug in glibc) by not duplicating the C locale object.  However,
that meant that there's only one copy running around.  And freeing that
will cause havoc, as its supposed to be there until destruction.  What
appears to be happening is that the current locale object is freed upon
thread destruction, and that could be this global one.  But I don't
understand why it's only happening on Free BSD and only on this version.
But this commit fixes the problem there, and makes sense.  Simply don't
free this global object upon thread destruction.

This commit also changes it so it doesn't get destroyed at destruction
time, leaving it to the final PERL_SYS_TERM to free.  I'm not sure, but
I think this fixes any issues with embedded perls.

4 years ago[perl #133892] coredump in Perl_re_intuit_start
Hugo van der Sanden [Mon, 25 Mar 2019 11:27:12 +0000 (11:27 +0000)]
[perl #133892] coredump in Perl_re_intuit_start

Make sure we have a valid non-utf8 'other' check substring before we
try to use it.

4 years agoperl5299delta: Fixes from errata
Karl Williamson [Tue, 26 Mar 2019 17:51:13 +0000 (11:51 -0600)]
perl5299delta: Fixes from errata

This makes the changes to this perldelta as listed in
07fbfc1d8cc566004b43d10c5bec8682b01400e8

This will make it easier to combine into the final 5.30 perldelta.

4 years agoperl5299delta: Clarify variable-length lookbehind entry
Tom Wyant [Tue, 26 Mar 2019 17:49:16 +0000 (11:49 -0600)]
perl5299delta: Clarify variable-length lookbehind entry

4 years agofix CvFILE() leak in Perl_newMYSUB()
David Mitchell [Tue, 26 Mar 2019 12:33:46 +0000 (12:33 +0000)]
fix CvFILE() leak in Perl_newMYSUB()

This is basically the same as my recent fix for Perl_newATTRSUB_x(),
v5.29.8-46-gb37d10f658.

When overwriting cv with the contents of PL_compcv, it was checking the
CvDYNFILE(cv) flag (to see if CvFILE(cv) needed freeing) *after*
overwriting cv's flags with PL_compcv's flag.

4 years agoavoid leak with local $h{foo}, $a[n]
David Mitchell [Tue, 26 Mar 2019 11:04:07 +0000 (11:04 +0000)]
avoid leak with local $h{foo}, $a[n]

When SAVEt_DELETE / SAVEt_ADELETE deletes a hash/array entry on scope
exit, they also decrement the refcount of the hash/array, and for the
hash, also free the saved key.

However, if the call to hv_delete() or av_delete() dies (e.g. when
calling a tied DELETE method) then the hash/array and key will leak
because leave_scope() calls av/hv_delete(), *then* does the
SvREFCNT_dec() etc.

The fix is to push new FREEPV/FREESV actions just before calling
av/hv_delete().

4 years agofix leak in package name lookup
David Mitchell [Tue, 26 Mar 2019 08:56:55 +0000 (08:56 +0000)]
fix leak in package name lookup

S_parse_gv_stash_name() mallocs a temporary buffer when scanning package
names longer than 64 bytes. Depending on how it exits the function, it
doesn't always free the buffer afterwards. Change the function so that
there are only two exit points (which free the buffer) and make other bits
of code goto those two points.

Can be reproduced with e.g.

&{"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'x"}

Similar code is already present in t/op/stash_parse_gv.t

4 years agofix a leak with indented heredocs
David Mitchell [Mon, 25 Mar 2019 20:13:30 +0000 (20:13 +0000)]
fix a leak with indented heredocs

With something like

   |print <<~EOF;
   | some data
   |   EOF

it croaks (as it should) with "Indentation ... doesn't match delimiter",
but in that case it leaks the recently malloc()d 'indent' buffer.

The fix is simple.  I've also fixed by code inspection where the code
does 'goto interminable', although I didn't try to reproduce the conditions
where the goto might occur.

4 years agoreformat S_scan_heredoc()
David Mitchell [Mon, 25 Mar 2019 19:44:57 +0000 (19:44 +0000)]
reformat S_scan_heredoc()

The indentation was inconsistent and confusing.

Reindent, add blank lines where appropriate, and change this code
comment: "(Closing '}' here to balance"  to '<<}', since vim is far too
clever for its own good these days in terms of using '%' to bounce
between brace pairs.

Should be no functional changes.

4 years agoS_scan_heredoc(): add cosmetic braces
David Mitchell [Mon, 25 Mar 2019 19:14:43 +0000 (19:14 +0000)]
S_scan_heredoc(): add cosmetic braces

add braces round a single-statement 'if' clause which contains a while
loop and spans several lines.

Should be functionally equivalent, but less visually confusing.

4 years agofix leak with local ${^WARNING_BITS} = ...
David Mitchell [Mon, 25 Mar 2019 17:18:58 +0000 (17:18 +0000)]
fix leak with local ${^WARNING_BITS} = ...

When restoring the old value, need to free the current value first.
Can be reproduced with

    {
        local ${^WARNING_BITS} = 'swit';
    }

when run under ASan or similar.
An equivalent test already exists in t/op/leaky-magic.t.

4 years agoIt's an error if any component of \p{user-defined} fails
Karl Williamson [Sun, 24 Mar 2019 20:36:50 +0000 (14:36 -0600)]
It's an error if any component of \p{user-defined} fails

A user-defined property can expand to more than one component that are
combined into a single result.  Prior to this commit, since the move of
this into core C, it was possible that if any component was valid, the
whole thing was considered valid, though in many instances an assertion
failed on DEBUGGING builds.

4 years agoregcomp.c: Fix comment
Karl Williamson [Sun, 24 Mar 2019 20:27:38 +0000 (14:27 -0600)]
regcomp.c: Fix comment

It wasn't quite accurate

4 years agoavoid leak assigning regexp to non-COW string
David Mitchell [Fri, 22 Mar 2019 17:38:48 +0000 (17:38 +0000)]
avoid leak assigning regexp to non-COW string

In something like

    $s = substr(.....); # $s now a non-COW SvPOK() SV
    $r = qr/..../;
    $s = $$r;

$s's previous string buffer would leak when an SVt_REGEXP type SV is
assigned to it.

Worse, if $s was an SVt_PVPV, it would fail an assert on debugging
builds.

The fix is to make sure any remaining stringy stuff is cleaned up
before copying the REGEXP.

4 years agofix leak in BEGIN { threads->new(...) }
David Mitchell [Fri, 22 Mar 2019 15:43:56 +0000 (15:43 +0000)]
fix leak in BEGIN { threads->new(...) }

Normally by the time we reach perl_destruct(), PL_parser should be null
due to having its original (null) value restored by SAVEt_PARSER during
leaving scope (usually before run-time starts in fact).  But if a thread
is created within a BEGIN block, the parser is duped, but the
SAVEt_PARSER savestack entry isn't. So PL_parser never gets cleaned up.
Clean it up in perl_destruct() instead. This is a bit of a hack.