This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
5 years agoregcomp.c: Don't restart parse for /d to /u if no need to
Karl Williamson [Wed, 7 Nov 2018 01:26:39 +0000 (18:26 -0700)]
regcomp.c: Don't restart parse for /d to /u if no need to

This commit keeps track of if there are any operations encountered which
differ under /d from /u.  If we switch to /u and haven't so far found
anything which differs, there's no need to reparse

5 years agoregcomp.c: Don't restart parse for /d to /u if reparsing anyway
Karl Williamson [Wed, 7 Nov 2018 01:10:36 +0000 (18:10 -0700)]
regcomp.c: Don't restart parse for /d to /u if reparsing anyway

Prior to this commit, if the rules changed from /d to /u, the parse was
immediately restarted.  This commit changes that so that it doesn't do
this if it is known that the parse will be redone anyway, but a full
parse needs to done first in order to count the parentheses.

Doing this can avoid the need for an almost full extra reparse.

5 years agoregcomp.c: Don't restart parse now if doing so later
Karl Williamson [Wed, 7 Nov 2018 01:02:07 +0000 (18:02 -0700)]
regcomp.c: Don't restart parse now if doing so later

Prior to this commit, if it became apparent that long branches were
going to be needed, the parse was immediately restarted.  This commit
changes that so that it doesn't do this if it is known that the parse
will be redone anyway, but a full parse needs to done first in order to
count the parentheses.

This can avoid an almost complete reparse in some situations.

5 years agoregcomp.c: Swap 'if' branches for readability
Karl Williamson [Wed, 7 Nov 2018 00:41:18 +0000 (17:41 -0700)]
regcomp.c: Swap 'if' branches for readability

It's easier to understand if the simplest case is first in the code.

5 years agoregcomp.c: Refactor constructing EXACTish nodes
Karl Williamson [Wed, 7 Nov 2018 00:31:21 +0000 (17:31 -0700)]
regcomp.c: Refactor constructing EXACTish nodes

The previous commits have allowed us to refactor this to eliminate
redundancies.

Previously, the same logic was done separately for UTF-8 and non-UTF-8
patterns.  This refactors so the logic is done once.  The details differ
for UTF-8 and non-UTF-8.  So that's where the differences lie, in the
details without having to duplicate the logic.

5 years agoregcomp.c: Fix up parsing \N{} in a string
Karl Williamson [Tue, 6 Nov 2018 17:03:00 +0000 (10:03 -0700)]
regcomp.c: Fix up parsing \N{} in a string

\N{} changes /d to /u, and may require reparsing of the current node to
fix wrong assumptions.

This commit is necessary for the simplifications achieved in the next
commit.

5 years agoregcomp.c: Remove obsolete code
Karl Williamson [Sat, 3 Nov 2018 16:03:37 +0000 (10:03 -0600)]
regcomp.c: Remove obsolete code

This code was obsoleted by removal of the sizing pass.  Previously we
had to take special care when encountering the LATIN SMALL LETTER SHARP
S because it can fold to more bytes than it occupies.  But with the
sizing pass gone, that is no longer necessary.

5 years agoregcomp.c: Comments, white-space, rmv extra parens
Karl Williamson [Sat, 3 Nov 2018 15:41:52 +0000 (09:41 -0600)]
regcomp.c: Comments, white-space, rmv extra parens

This commit re-indents things after the previous commit added a block,
fixes typos in comments, and removes obsolete references in them to the
sizing pass, and adds some comments, and does some white-space changes.
In one case it removes extraneous parentheses

5 years agoregcomp.c: Remove no longer useful code
Karl Williamson [Thu, 1 Nov 2018 15:08:04 +0000 (09:08 -0600)]
regcomp.c: Remove no longer useful code

This code has been obsoleted by the previous commit.  That commit looks
at a bracketed character class in general and optimizes it to some
faster and/or simpler operation if possible.  The code being removed in
this commit was originally added to try to find some optimizations that
were feasible to find in the sizing pass.  Now that we don't have a
sizing pass, and we find optimizations generally, this code doesn't add
any value.

5 years agoFind optimizations for /[[:posix:]]/a
Karl Williamson [Thu, 1 Nov 2018 07:43:39 +0000 (01:43 -0600)]
Find optimizations for /[[:posix:]]/a

Various optimizations are done when the regular expression compiler sees
a bracketed character class.  For example, /[a]/ is optimized into /a/.
This wasn't done for the various POSIX classes under /a, as the speed of
the operations of using a regular bracketed class (which uses a bitmap)
and of an optimized version (which uses a specialized opcode for the
POSIX class) is similar.  The only advantage would have been that the
specialized opcode is 1/10 the size of the bitmap.  But the optimization
in general couldn't come until the second pass, after the size had
already been calculated and space allocated.  So there was no savings.

But now that there is no separate sizing pass, doing the optimization
actually will save space.

5 years agoregcomp.c: Add assertion
Karl Williamson [Mon, 12 Nov 2018 04:54:41 +0000 (21:54 -0700)]
regcomp.c: Add assertion

5 years agoregcomp.c: Fix up RE_TRACK_PATTERN_OFFSETS
Karl Williamson [Wed, 14 Nov 2018 16:09:38 +0000 (09:09 -0700)]
regcomp.c: Fix up RE_TRACK_PATTERN_OFFSETS

These need to be changed around as a result of removing the sizing pass
from pattern compilation.

The first element in the array is the number of offsets.  This had
become wrong.  And it is used instead of the program length when it is
available.

5 years agoregcomp.c: Avoid some conditionals
Karl Williamson [Sat, 20 Oct 2018 23:24:53 +0000 (17:24 -0600)]
regcomp.c: Avoid some conditionals

A pattern being UTF-8 implies it is /u.  By proper initialization of if
it is /u or not, we can avoid the existing additional tests for UTF-8 in
those places where we care about /u but don't care about UTF-8ness.

5 years agoregcomp.c: Make sure UTF-8 regex pattern uses /u
Karl Williamson [Mon, 29 Oct 2018 03:24:22 +0000 (21:24 -0600)]
regcomp.c: Make sure UTF-8 regex pattern uses /u

When a pattern is in UTF-8, Unicode rules should be selected.  This
commit makes sure that this happens and that the displayable form of the
pattern shows /u.

I don't know of any bugs this fixes.

5 years agoPATCH: [perl #133642] Double free
Karl Williamson [Thu, 8 Nov 2018 03:22:36 +0000 (20:22 -0700)]
PATCH: [perl #133642] Double free

This was caused by doing a SAVEFREEPV twice.  The solution is to not do
this twice.

But this means that if the process unexpectedly dies, there is a
potential memory leak.  That potential already exists with other
variables, and has its own ticket #133589.

5 years agoregcomp.c: Refactor to remove an else and a NOT_REACHED
Karl Williamson [Thu, 8 Nov 2018 03:07:51 +0000 (20:07 -0700)]
regcomp.c: Refactor to remove an else and a NOT_REACHED

This just simplifies things a bit.

5 years agoregcomp.c: calculate variants instead of assuming worst case
Karl Williamson [Thu, 8 Nov 2018 03:20:53 +0000 (20:20 -0700)]
regcomp.c: calculate variants instead of assuming worst case

When converting a byte pattern to UTF-8, the needed size may increase due
to some bytes (the UTF-8 variants) occupying two bytes instead of one
under UTF-8.

Prior to this commit, the pattern was assumed to contain only variants,
and enough memory was allocated for the worst case.

This commit actually calculates how much space is needed and allocates
only that.

There is extra work involved in doing this calculation.  But the pattern
is parsed per-word.  For short strings, it doesn't much matter either
way.  But for very long strings, it seems to me the consequences of
potentially allocating way too much memory out weighs the negative of
this extra work.  If field experience proves me wrong, then revert this
commit.

5 years agoXXX utf8.c: calculate vairants instead of assuming worst case
Karl Williamson [Thu, 8 Nov 2018 03:11:50 +0000 (20:11 -0700)]
XXX utf8.c: calculate vairants instead of assuming worst case

When converting a byte string to UTF-8, the needed size may increase due
to some bytes (the UTF-8 variants) occupying two bytes instead of one
under UTF-8.

Prior to this commit, the string was assumed to contain only variants,
and enough memory was allocated for the worst case, then the excess was
returned at the end.

This commit actually calculates how much space is needed and allocates
only that, so there is no need to trim afterwards.

There is extra work involved in doing this calculation.  But the string
is parsed per-word.  For short strings, it doesn't much matter either
way.  But for very long strings, it seems to me the consequences of
potentially allocating way too much memory out weighs the negative of
this extra work.

5 years agoregcomp.sym: longj field is a boolean
Karl Williamson [Mon, 12 Nov 2018 04:48:53 +0000 (21:48 -0700)]
regcomp.sym: longj field is a boolean

The comments could lead one to thinking one could specify any of the
argument fields that nodes can have.  But in fact, the value is a
boolean, 0 meaning to use the normal offset field of all regnodes; and 1
meaning to use the ARG field that some regnodes have.  If a regnode had
more than just the one argument field, the one that corresponds to that
would be used.

This commit enforces that, and changes regcomp.sym to not use  '2',
which is misleading.

It clarifies the comments about this and what '.' means in the flags
field

5 years agot/re/reg_mesg.t: Add test
Karl Williamson [Thu, 8 Nov 2018 01:44:56 +0000 (18:44 -0700)]
t/re/reg_mesg.t: Add test

Verify this still works after the recent removal of the sizing pass

5 years ago-Drv now turns on all regex debugging
Karl Williamson [Mon, 12 Nov 2018 04:42:51 +0000 (21:42 -0700)]
-Drv now turns on all regex debugging

This commit makes the v (verbose) modifier to -Dr do something: turn on
all possible regex debugging.

5 years agoregcomp.h: Delete duplicate macro defn
Karl Williamson [Mon, 12 Nov 2018 04:38:29 +0000 (21:38 -0700)]
regcomp.h: Delete duplicate macro defn

5 years agoperl.h: White-space, comment
Karl Williamson [Sun, 11 Nov 2018 22:59:14 +0000 (15:59 -0700)]
perl.h: White-space, comment

5 years agore/re_tests: Add test
Karl Williamson [Sun, 11 Nov 2018 18:31:17 +0000 (11:31 -0700)]
re/re_tests: Add test

5 years agohandy.h: Add some comments
Karl Williamson [Thu, 8 Nov 2018 01:40:37 +0000 (18:40 -0700)]
handy.h: Add some comments

This allows us to remove a comment in regcomp.c

5 years agoperlrun: Clarify -Dv
Karl Williamson [Wed, 14 Nov 2018 16:21:04 +0000 (09:21 -0700)]
perlrun: Clarify -Dv

5 years agot/re/pat.t: Add a test
Karl Williamson [Tue, 6 Nov 2018 16:51:53 +0000 (09:51 -0700)]
t/re/pat.t: Add a test

5 years agolgtm.yml: classify charclass_invlists.h as generated
Dominic Hargreaves [Thu, 15 Nov 2018 12:13:05 +0000 (12:13 +0000)]
lgtm.yml: classify charclass_invlists.h as generated

This file represents a significant chunk of the line count of the project
and so excluding it results in more realistic statistics.

5 years agoAdd ext/File-Find/t to list of badly-behaved test directories.
James E Keenan [Wed, 14 Nov 2018 21:29:46 +0000 (16:29 -0500)]
Add ext/File-Find/t to list of badly-behaved test directories.

For: RT # 133658

5 years agoEnable LGTM.com integration
Dominic Hargreaves [Tue, 6 Nov 2018 16:55:41 +0000 (16:55 +0000)]
Enable LGTM.com integration

Committer: Update MANIFEST.  Provide additional email address for
contributor.

5 years agoAdd more parallelism to t/harness
Karl Williamson [Wed, 25 Jul 2018 02:26:39 +0000 (20:26 -0600)]
Add more parallelism to t/harness

This commit causes test files in cpan/, etc to run in parallel provided
there is no file in the test directory whose name begins with zero.
Experience shows that things like 01test, 02test, ... are supposed to be
executed serially.  Sometimes there is a single file beginning with 0,
and this is supposed to be executed first as setup for the remaining
tests (which probably could be executed in parallel, but that
enhancement is much harder to do, so isn't tried here)

This is a heuristic, and this commit adds the ability to explicitly
specify directories to the serial list that don't correspond to the
above rule.  One directory is currently on that list: ext/Pod-Html/t.
It follows a different paradigm to order things.  We could rename the
tests to follow the normal paradigm since this is in ext/, but I thought
it best to keep it as an example of what to do should the need for other
exceptions arise.

This can save a bunch of wallclock time on slower systems with many
cores, such as dromedary.  On that system, the test suite finishes 17%
faster with this commit on the first run.  (This is a savings of over
100 wallclock seconds; a very noticeable improvement.)  On subsequent
runs when it knows approximately how long each test takes and sorts the
order accordingly, the suite runs 8% faster.

On machines with few cores, there isn't much of a difference.

5 years agoFix missing build dependency for pods
Dan Dedrick [Fri, 13 Oct 2017 01:49:39 +0000 (21:49 -0400)]
Fix missing build dependency for pods

When building perl with highly parallel options (e.g. -j 32) on a machine
with many cores (e.g. 32) ocassionaly it fails with the following type
of error.

make[1]: Entering directory '.../cpan/podlators'
Can't locate Getopt/Long.pm in @INC (you may need to install the Getopt::Long module) (@INC contains: .../cpan/AutoLoader/lib .../dist/Carp/lib .../dist/PathTools .../dist/PathTools/lib .../cpan/ExtUtils-Install/lib .../cpan/ExtUtils-MakeMaker/lib .../cpan/ExtUtils-Manifest/lib .../cpan/File-Path/lib .../ext/re .../dist/Term-ReadLine/lib .../dist/Exporter/lib .../ext/File-Find/lib .../cpan/Text-Tabs/lib .../dist/constant/lib .../cpan/version/lib .../lib ../../lib .) at .../cpan/ExtUtils-MakeMaker/lib/ExtUtils/Command/MM.pm line 109.
Makefile:445: recipe for target 'manifypods' failed
make[1]: *** [manifypods] Error 2

The scripts pod2man, pod2text, podchecker, podselect, and pod2usage all use
Getopt-Long and since they are all part of nonxs modules this needs to be
added here to prevent these build races.

5 years agoAdding Zak for March release
Sawyer X [Sun, 11 Nov 2018 08:54:10 +0000 (10:54 +0200)]
Adding Zak for March release

5 years agoEnsure same count of tests on different OSes.
James E Keenan [Sat, 10 Nov 2018 02:21:30 +0000 (21:21 -0500)]
Ensure same count of tests on different OSes.

On OpenBSD (in at least one instance), $different was false, thereby causing 30 tests not to be run but without reflecting that skipping in the test count displayed at the end of output.

Let's put this in a SKIP block similar to those used elsewhere in the file.

5 years agoBump Data::Dumper to 2.173 (no real change):
Sawyer X [Sat, 10 Nov 2018 10:06:59 +0000 (12:06 +0200)]
Bump Data::Dumper to 2.173 (no real change):

The change will happen in the Makefile.PL which is generated and
released. It is generated automatically, so we can't actually inject
the parts that we want.

The way I handle it at the moment is:

* Build perl
* Copy Data::Dumper to other directory
* Grab MANIFEST.SKIP and Makefile.PL from previous release
* Add the DEFINE we need to fix this:

    # In WriteMakefile(...)
    DEFINE        => '-DUSE_PPPORT_H',

* perl Makefile.PL && make && make test && make dist
* Retest the tarball
* Release to CPAN

But we need this bump anyway, so this commit.

5 years agoext/re/t/qr.t: Rmv extraneous Debug statement
Karl Williamson [Mon, 5 Nov 2018 18:01:35 +0000 (11:01 -0700)]
ext/re/t/qr.t: Rmv extraneous Debug statement

It looks like this statement to turn on Debugging was used to help debug
the issues that this test now tests, and should have been removed when
the file was first commited.  But no harm came, as no debugging output
got generated.

This was changed by commit 15cab4d70522286feb2fcb1e7313b2f995343181,
"Remove references to passes from regex compiler".  It unknowingly fixed
a bug wherein a Debug statement didn't get output.  That cause qr.t to
output that debugging statement.

The fix is to simply remove the call for Debugging from qr.t

5 years agoDon't localise array / hash slice ref assignment
David Mitchell [Mon, 5 Nov 2018 12:29:27 +0000 (12:29 +0000)]
Don't localise array / hash slice ref assignment

RT #133538

The experimental ref assignment aliasing feature, when applied to
array or hash slices, was treating the slice as if it was always localized;
e.g.

    \(@a[3,5,7]) = \(....);

was being interpreted as

    local \(@a[3,5,7]) = \(....);

The fix is simple: check for the OPpLVAL_INTRO flag actually being set
on the op, rather than unconditionally localising the array/hash
elements.

5 years ago(perl #132147) bump *DBM_File versions
Tony Cook [Wed, 24 Jan 2018 04:10:10 +0000 (15:10 +1100)]
(perl #132147) bump *DBM_File versions

5 years ago(perl #132147) add security warnings to the *DBM_File modules
Tony Cook [Wed, 24 Jan 2018 04:03:39 +0000 (15:03 +1100)]
(perl #132147) add security warnings to the *DBM_File modules

5 years agopp_divide: use modulo instead of multiplication
Tomasz Konojacki [Mon, 15 Oct 2018 03:24:27 +0000 (05:24 +0200)]
pp_divide: use modulo instead of multiplication

On most architectures with hardware integer division (like
x86 or aarch64), division instruction returns both the remainder
and the quotient. It means that performing modulo operation
immediately after division using the same operands is 100% free.

Essentially this commit changes "div" and "mul" into a single "div"
instruction, which results in minor speed up.

[perl #133511]

5 years ago(perl #127606) adjust dependency paths on installation on darwin
Tony Cook [Thu, 4 Oct 2018 04:41:03 +0000 (14:41 +1000)]
(perl #127606) adjust dependency paths on installation on darwin

SIP (System Integrity Protection) on OS X prevents the
DYLD_LIBRARY_PATH environment variable from being propagated through
/bin/sh, causes many tests to fail (and some more recent build issues)
for -Duseshrplib builds.

To avoid that, we change the way libperl.dylib is linked to perl, so
for the initial build the library's id is at the build location rather
than the install location, and the generated executable also expects
to find libperl in that location.

This obviously won't work once we copy both to the installation
directory, so we adjust both the id of the library and the dependency
path in the executable to point to the new location of the library.

A previous attempt set -rpath and used @rpath in the id, but this made
the embedding test fail.

5 years agoCorrect spelling error
James E Keenan [Thu, 1 Nov 2018 21:17:03 +0000 (17:17 -0400)]
Correct spelling error

5 years agoperlfunc: highlight -X behaviour on dangling symlinks
David Cantrell [Thu, 1 Nov 2018 11:10:49 +0000 (11:10 +0000)]
perlfunc: highlight -X behaviour on dangling symlinks

5 years agobump $File::Spec::*::VERSION
Tony Cook [Thu, 1 Nov 2018 02:54:28 +0000 (13:54 +1100)]
bump $File::Spec::*::VERSION

5 years agoprevent t/Functions.t from warning on undefined values when none supplied
Tony Cook [Thu, 1 Nov 2018 02:44:52 +0000 (13:44 +1100)]
prevent t/Functions.t from warning on undefined values when none supplied

5 years agoHandle OSes where filesystems can be mounted with 'noatime' option
James E Keenan [Wed, 31 Oct 2018 23:03:19 +0000 (19:03 -0400)]
Handle OSes where filesystems can be mounted with 'noatime' option

Adapted from http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/perl5/patches/patch-ta?rev=1.6&content-type=text/x-cvsweb-markup

For readability, change a 'skip' whose block lacked tests to be skipped
with a simple 'pass'.

For RT 132663

5 years agoPATCH: [perl #133620] heap buffer overflow
Karl Williamson [Wed, 31 Oct 2018 16:22:03 +0000 (10:22 -0600)]
PATCH: [perl #133620] heap buffer overflow

This happens when an alternate parse string is constructed, and the
error message needs to be translated into the terms of the original one,
the error is just past the right edge.  The translation was not getting
done.  Simply use the original terms.

5 years agoMove subroutine definition to end of file.
James E Keenan [Mon, 29 Oct 2018 21:56:20 +0000 (17:56 -0400)]
Move subroutine definition to end of file.

Thereby improving readability of main program.

5 years agoRegularize indents within subroutine definition.
James E Keenan [Mon, 29 Oct 2018 21:39:48 +0000 (17:39 -0400)]
Regularize indents within subroutine definition.

Over decades, the code within the subroutine acquired many different
combinations of tabs and whitespace for indents, thereby making the code
less readable.  Standardize on 4 whitespaces.

For readability, comment end of two blocks.

5 years agoFully encapsulate check_utime_result()
James E Keenan [Mon, 29 Oct 2018 21:34:22 +0000 (17:34 -0400)]
Fully encapsulate check_utime_result()

This will permit us to move the subroutine's definition to the end of
the file, thereby improving readability of main program.

5 years agoRemove code commented out since March 2002.
James E Keenan [Mon, 29 Oct 2018 21:19:07 +0000 (17:19 -0400)]
Remove code commented out since March 2002.

Align indents after removal of comments.

5 years agoRepeatedly hard-coding an integer is a mistake.
James E Keenan [Mon, 29 Oct 2018 21:07:09 +0000 (17:07 -0400)]
Repeatedly hard-coding an integer is a mistake.

Place 500000000 in variable $ut.

5 years agoMake descriptions more self-documenting
James E Keenan [Mon, 29 Oct 2018 21:00:50 +0000 (17:00 -0400)]
Make descriptions more self-documenting

So that while debugging we can see which 'atime' and 'utime' cases we
are handling.

5 years agoAdd notes so it's easier to see where we are in test file.
James E Keenan [Mon, 29 Oct 2018 20:44:31 +0000 (16:44 -0400)]
Add notes so it's easier to see where we are in test file.

5 years agoUse t/test.pl's note() function
James E Keenan [Mon, 29 Oct 2018 20:35:35 +0000 (16:35 -0400)]
Use t/test.pl's note() function

... rather than print(), for informational statements.

5 years agoAdd minix hints to MANIFEST
H.Merijn Brand [Tue, 30 Oct 2018 16:41:37 +0000 (17:41 +0100)]
Add minix hints to MANIFEST

5 years agoAdd initial support for Minix3
H.Merijn Brand [Tue, 30 Oct 2018 16:39:33 +0000 (17:39 +0100)]
Add initial support for Minix3

Patch by Sevan Janiyan

Include a hints file for Minix, derived from the NetBSD one but stripped
back to remove most of the legacy parts.

5 years agoDefine also Perl's calloc() macro
Pali [Fri, 28 Sep 2018 11:17:01 +0000 (13:17 +0200)]
Define also Perl's calloc() macro

Functions malloc(), realloc() and free() are already redefined to
PerlMem_malloc(), PerlMem_realloc() and PerlMem_free(). But calloc() not.

This leads to the problem that memory by calloc() is allocated by system
C library, but freed by Perl's PerlMem_free() which just cause memory
corruptions.

5 years agoNote locales available and those used in tests.
James E Keenan [Mon, 29 Oct 2018 00:29:14 +0000 (20:29 -0400)]
Note locales available and those used in tests.

This will facilitate diagnosis of problems on platforms where tests in
this file are failing.

5 years agoremove extra 'be' in perlre pod
Phil Pearl (Lobbes) [Fri, 26 Oct 2018 17:34:26 +0000 (13:34 -0400)]
remove extra 'be' in perlre pod

Committer: Add author.

5 years agoCast away const from AIX' accessx() path argument
Dagfinn Ilmari Mannsåker [Thu, 23 Nov 2017 11:29:19 +0000 (11:29 +0000)]
Cast away const from AIX' accessx() path argument

Unlike every other platform's access() or equivalent (and as required
by POSIX), AIX doesn't declare the path argument to access() and
accessx() as const char*, so cast the const away.

5 years ago(perl #133604) fix binmode on Win32 :crlf layers origin/tonyc/133604-crlf-binmode-utf8
Tony Cook [Mon, 22 Oct 2018 04:22:47 +0000 (15:22 +1100)]
(perl #133604) fix binmode on Win32 :crlf layers

On Win32 the :crlf layer is special - it replaces the use of the normal
:perlio buffering layer.

So while binmode :raw with :crlf present on non-Win32 removes the
CRLF layer, on Win32 it simply switches the :crlf layer's CRLF flag off
to prevent translation.

Unfortunately the :crlf skipped doing something else expected by :raw -
it didn't turn off the layer UTF8 flag.  This broke the tests I added
in 9704d779004.

5 years ago(perl #133604) test for binmode removing :utf8
Tony Cook [Mon, 22 Oct 2018 02:24:48 +0000 (13:24 +1100)]
(perl #133604) test for binmode removing :utf8

5 years ago(perl #133604) skip a new test on Win32 that fails only on Win32
Tony Cook [Sun, 21 Oct 2018 22:44:57 +0000 (09:44 +1100)]
(perl #133604) skip a new test on Win32 that fails only on Win32

9704d779 added tests for the apparently completely untested behaviour
of recv() and send() on handles marked as :utf8.

On Win32 the binmode calls used to strip :utf8 for further testing
don't remote :utf8, and the following calls to send() and recv() die.

Hopefully this patch will be reverted soon once binmode is fixed.

5 years agoUsing #ifdef inside macro arguments confuses VC++ 2008
Tony Cook [Sat, 20 Oct 2018 23:40:46 +0000 (10:40 +1100)]
Using #ifdef inside macro arguments confuses VC++ 2008

This caused compilation errors for me when building with the
Windows 7 SDK packaged version of MSVC.

5 years agoBump version of Module::CoreList in Maintainers.pl
Aaron Crane [Sat, 20 Oct 2018 15:07:16 +0000 (16:07 +0100)]
Bump version of Module::CoreList in Maintainers.pl

5 years agoBump the Perl version for 5.29.5
Aaron Crane [Sat, 20 Oct 2018 14:43:30 +0000 (15:43 +0100)]
Bump the Perl version for 5.29.5

5 years agoCreate new perldelta for 5.29.5-to-be
Aaron Crane [Sat, 20 Oct 2018 14:32:02 +0000 (15:32 +0100)]
Create new perldelta for 5.29.5-to-be

5 years agoTick off 5.29.4 release
Aaron Crane [Sat, 20 Oct 2018 14:28:55 +0000 (15:28 +0100)]
Tick off 5.29.4 release

5 years agoEpigraph for 5.29.4 release
Aaron Crane [Sat, 20 Oct 2018 14:28:31 +0000 (15:28 +0100)]
Epigraph for 5.29.4 release

5 years agoMerge branch 'release-5.29.4' into blead
Aaron Crane [Sat, 20 Oct 2018 14:25:18 +0000 (15:25 +0100)]
Merge branch 'release-5.29.4' into blead

5 years agoFinalize perldelta for 5.29.4 v5.29.4
Aaron Crane [Sat, 20 Oct 2018 12:29:17 +0000 (13:29 +0100)]
Finalize perldelta for 5.29.4

5 years agoUpdate Module::Corelist for 5.29.4
Aaron Crane [Sat, 20 Oct 2018 12:29:01 +0000 (13:29 +0100)]
Update Module::Corelist for 5.29.4

5 years agoMerge branch 'remove sizing pass' into blead
Karl Williamson [Sat, 20 Oct 2018 06:10:25 +0000 (00:10 -0600)]
Merge branch 'remove sizing pass' into blead

5 years agoperldelta
Karl Williamson [Sat, 20 Oct 2018 03:41:35 +0000 (21:41 -0600)]
perldelta

5 years agoregcomp.c: White space only
Karl Williamson [Fri, 19 Oct 2018 20:55:35 +0000 (14:55 -0600)]
regcomp.c: White space only

This out/indents the blocks that were removed/added by the previous
commit

5 years agoRemove references to passes from regex compiler
Karl Williamson [Fri, 19 Oct 2018 17:39:57 +0000 (11:39 -0600)]
Remove references to passes from regex compiler

The previous commit removed the sizing pass, but to minimize the
difference listing, it left in all the references it could to the
various passes, with the first pass set to FALSE.  This commit now
removes those references, as well as to some variables that are no
longer used.

5 years agoRemove sizing pass from regular expression compiler
Karl Williamson [Fri, 19 Oct 2018 15:48:34 +0000 (09:48 -0600)]
Remove sizing pass from regular expression compiler

This commit removes the sizing pass for regular expression compilation.
It attempts to be the minimum required to do this.  Future patches are
in the works that improve it,, and there is certainly lots more that
could be done.

This is being done now for security reasons, as there have been several
bugs leading to CVEs where the sizing pass computed the size improperly,
and a crafted pattern could allow an attack.  This means that simple
bugs can too easily become attack vectors.

This is NOT the AST that people would like, but it should make it easier
to move the code in that direction.

Instead of a sizing pass, as the pattern is parsed, new space is
malloc'd for each regnode found.  To minimize the number of such mallocs
that actually go out and request memory, an initial guess is made, based
on the length of the pattern being compiled.  The guessed amount is
malloc'd and then immediately released.  Hopefully that memory won't be
gobbled up by another process before we actually gain control of it.
The guess is currently simply the number of bytes in the pattern.
Patches and/or suggestions are welcome on improving the guess or this
method.

This commit does not mean, however, that only one pass is done in all
cases.  Currently there are several situations that require extra
passes.  These are:

    a)  If the pattern isn't UTF-8, but encounters a construct that
        requires it to become UTF-8, the parse is immediately stopped,
        the translation is done, and the parse restarted.  This is
        unchanged from how it worked prior to this commit.
    b)  If the pattern uses /d rules and it encounters a construct that
        requires it to become /u, the parse is immediately stopped and
        restarted using /u rules.  A future enhancement is to only
        restart if something has been encountered that would generate
        something different than what has already been generated, as
        many operations are the same under both /d and /u.  Prior to
        this commit, in rare circumstances was the parse immediately
        restarted.  Only those few that changed the sizing did so.
        Instead the sizing pass was allowed to complete and then the
        generation pass ran, using /u.  Some CVEs were caused by faulty
        implementation here.
    c)  Very large patterns may need to have long jumps in their
        program.  Prior to this commit, that was determined in the
        sizing pass, and all jumps were made long during generation.
        Now, the first time the need for a long jump is detected, the
        parse is immediately restarted, and all jumps are made long.  I
        haven't investigated enough to be sure, but it might be
        sufficient to just redo the current jump, making it long, and
        then switch to using just long jumps, without having to restart
        the parse from the beginning.
    d)  If a reference that could be to capturing parentheses doesn't
        find such parentheses, a flag is set.  For references that could
        be octal constants, they are assumed to be those constants
        instead of a capturing group.  At the end of the parse, if the
        flag indicates either that the assumption(s) were wrong or that
        it is a fatal reference to a non-existent group, the pattern is
        reparsed knowing the total number of these groups.
    e)  If (?R) or (?0) are encountered, the flag listed in item d)
        above is set to force a reparse.  I did have code in place that
        avoided doing the reparse, but I wasn't confident enough that
        our test suite exercises that area of the code enough to have
        exposed all the potential interaction bugs, and I think this
        construct is used rarely enough to not worry about avoiding the
        reparse at this point in the development.
    f)  If (?|pattern) is encountered, the behavior is the same as in
        item e) above.  The pattern will end up being reparsed after the
        total number of parenthesized groups are known.  I decided not
        to invest the effort at this time in trying to get this to work
        without a reparse.

It might be that if we are continuing the parse to just count
parentheses, and we encounter a construct that normally would restart
the parse immediately, that we could defer that restart.  This would cut
down the maximum number of parses required.  As of this commit, the
worst case is we find something that requires knowing all the
parentheses; later we have to switch to /u rules and so the parse is
restarted.  Still later we have to switch to long jumps, and the parse
is restarted again.  Still later we have to upgrade to UTF-8, and the
parse is restarted yet again.  Then the parse is completed, and the
final total of parentheses is known, so everything is redone a final
time.  Deferring those intermediate restarts would save a bunch of
reparsing.

Prior to this commit, warnings were issued only during the code
generation pass, which didn't get called unless the sizing pass(es)
completed successfully.  But now, we don't know if the pass will
succeed, fail, or whether it will have to be restarted.  To avoid
outputting the same warning more than once, the position in the parse of
the last warning generated is kept (across parses).  The code looks at
that position when it is about to generate a warning.  If the parsing
has previously gotten that far, it assumes that the warning has already
been generated, and suppresses it this time.  The current state of
parsing is such that I believe this assumption is valid.  If the parses
had divergent paths, that assumption could become invalid.

5 years agoregcomp.c: Avoid potential NULL ptr dereference
Karl Williamson [Fri, 19 Oct 2018 17:49:01 +0000 (11:49 -0600)]
regcomp.c: Avoid potential NULL ptr dereference

This commit cause the passed in variable to be non-NULL before
dereferencing it, as defensive coding practice.  A future commit causes
this to matter.

5 years agoregcomp.c: Test that code block exists before cleaning
Karl Williamson [Fri, 19 Oct 2018 17:47:05 +0000 (11:47 -0600)]
regcomp.c: Test that code block exists before cleaning

This is defensive coding progress, to avoid dereferencing a NULL ptr.

5 years agoregcomp.c: Extract code into a function
Karl Williamson [Fri, 19 Oct 2018 01:58:45 +0000 (19:58 -0600)]
regcomp.c: Extract code into a function

This should have no changes in behavior, and is for a future commit
where this code will be called from a second place.

5 years agoregcomp.c: Test for having /u earlier for \p{}
Karl Williamson [Fri, 19 Oct 2018 01:02:51 +0000 (19:02 -0600)]
regcomp.c: Test for having /u earlier for \p{}

When \p{} or \p{} are encountered during parsing, that indicates that
the pattern should be compiled not under /d, but under /u, as these are
Unicode constructs.  This commit moves the test for that to somewhat
earlier.  This saves only a little work currently, but in a future
commit it saves a lot more wasted work.

5 years agoregcomp.c: Remove variable in favor of struct element
Karl Williamson [Wed, 17 Oct 2018 17:54:49 +0000 (11:54 -0600)]
regcomp.c: Remove variable in favor of struct element

The code has a structure element that means the same thing part way
through a function as a variable.  Just use the struct element all the
way through

5 years agoregcomp.c: Move fcn call out of loop
Karl Williamson [Tue, 16 Oct 2018 18:16:10 +0000 (12:16 -0600)]
regcomp.c: Move fcn call out of loop

The loop in this case is by a goto label, and the function determines if
there are runtime code blocks in the pattern.  That doesn't change if we
have to reparse, so the return from the function doesn't change, so we
only have to call it once.

5 years agoregcomp.c: Extract code into a function
Karl Williamson [Tue, 16 Oct 2018 03:31:13 +0000 (21:31 -0600)]
regcomp.c: Extract code into a function

This is in preparation for a later commit where the code will become
more complex and be called from more than one place.

5 years agoregcomp.c: Consolidate checks for warnings fatality
Karl Williamson [Mon, 15 Oct 2018 03:12:15 +0000 (21:12 -0600)]
regcomp.c: Consolidate checks for warnings fatality

This adds code so that whenever a warning is about to be emitted, it
first checks to see if the warning is fatal, and if so mortalizes the SV
that otherwise would leak.

This partially fixes ticket [perl #133589].  It doesn't help if the
warnings are called through a subroutine outside of regcomp.c

5 years agoregcomp.c: Add macro for warnings output
Karl Williamson [Sun, 14 Oct 2018 23:07:57 +0000 (17:07 -0600)]
regcomp.c: Add macro for warnings output

This macro does nothing for now.  It is being added in this separate
commit to lessen the number of differences in the future commit that
will need it, so that these don't distract from the main intent of that
commit.

The code is moving away from emitting all warnings in the code
generation pass, to emitting them as soon as encountered.  But to avoid
emitting them more than once should the pattern have to be reparsed,
they will not be emitted unless the parse has gotten further this time
than it got earlier.  This commit prepares for that.

5 years agoregcomp.c: Defer setting the OP variant of a regnode
Karl Williamson [Sun, 14 Oct 2018 22:59:50 +0000 (16:59 -0600)]
regcomp.c: Defer setting the OP variant of a regnode

This is in preparation for a future commit.  We have allocated space and
know that the regnode will be some time of ANYOF one.  But we don't need
to know which one precisely until later than we had been setting it.

5 years agoregcomp.c: Defer setting regnode operand
Karl Williamson [Sun, 14 Oct 2018 22:50:59 +0000 (16:50 -0600)]
regcomp.c: Defer setting regnode operand

Don't set this until we know that we are actually going to have a
regnode that requires this operand.

5 years agoregcomp.c: Defer setting flags of a regnode
Karl Williamson [Sun, 14 Oct 2018 22:43:06 +0000 (16:43 -0600)]
regcomp.c: Defer setting flags of a regnode

This is in preparation for a future commit where we won't know what the
regnode is until later in the code.

5 years agoregcomp.c: Move some declarations
Karl Williamson [Sun, 14 Oct 2018 22:19:27 +0000 (16:19 -0600)]
regcomp.c: Move some declarations

This is in preparation for some blocks to be removed in a future commit,
so the declarations have to be at the top of the enclosing block

5 years agoregcomp.c: Add some const's to static fcn
Karl Williamson [Sun, 14 Oct 2018 22:10:01 +0000 (16:10 -0600)]
regcomp.c: Add some const's to static fcn

Since it's static, the compiler can figure out these are consts, but
knowing this helped me read the code

5 years agoregcomp.c: Use an equivalent 'if' condition
Karl Williamson [Sun, 14 Oct 2018 22:02:09 +0000 (16:02 -0600)]
regcomp.c: Use an equivalent 'if' condition

By inspection of the code, I see that this 'if' won't get executed
unless the variable is non-null.  The function whose return sets it
will raise an error if it would otherwise return NULL unexpectedly.

5 years agoregcomp.c: Reorder 'if' clauses
Karl Williamson [Sun, 14 Oct 2018 21:56:57 +0000 (15:56 -0600)]
regcomp.c: Reorder 'if' clauses

This is for sake of clarity so that the comment applies to the adjacent
clause.

5 years agoregcomp.c: Rmv unnecessary else
Karl Williamson [Sun, 14 Oct 2018 21:50:55 +0000 (15:50 -0600)]
regcomp.c: Rmv unnecessary else

The 'if' if executed aborts, so control would never reach here unless
the 'else' would be taken.

5 years agoregcomp.c: Use SvREFCNT_inc_NN()
Karl Williamson [Sun, 14 Oct 2018 21:12:41 +0000 (15:12 -0600)]
regcomp.c: Use SvREFCNT_inc_NN()

We know this is non-null as it panics a little ways above unless that's
the case.

5 years agoregcomp.c: Use an equivalent 'if' condition
Karl Williamson [Sun, 14 Oct 2018 20:30:50 +0000 (14:30 -0600)]
regcomp.c: Use an equivalent 'if' condition

By inspection of the code, I see that this 'if' won't get executed
unless the variable is non-null.  The function whose return sets it
will raise an error if it would otherwise return NULL unexpectedly.

5 years agoregcomp.c: Combine expression into a macro
Karl Williamson [Sun, 14 Oct 2018 19:56:21 +0000 (13:56 -0600)]
regcomp.c: Combine expression into a macro

This expression will change in a future commit, so this isolates that
change

5 years agoregcomp.c: Split variable into two
Karl Williamson [Sun, 14 Oct 2018 19:34:47 +0000 (13:34 -0600)]
regcomp.c: Split variable into two

This commit causes there to now be two variables that count the number
of parentheses in a pattern:
    a) the current number as the pattern is parsed
    b) the total number, not known until the pattern has been completely
       parsed

This will prove useful in later commits.

5 years agoConsolidate code into a single macro
Karl Williamson [Mon, 15 Oct 2018 02:16:03 +0000 (20:16 -0600)]
Consolidate code into a single macro

If we die during the code generation phase, we set the regex SV to be
freed during cleanup.

This consolidates many of those instances into one macro, so that it can
be easily changed.  And instead of tieing it to the particular phase, we
clean up whenever that SV actually exists.  This requires initializing
it to NULL.