This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years agoStorable: cygwin64 MAX_DEPTH /2
Reini Urban [Wed, 17 May 2017 20:40:59 +0000 (22:40 +0200)]
Storable: cygwin64 MAX_DEPTH /2

(cherry picked from commit 5c3259bf9a54c29b526cb36cdf155005d8f93236)

6 years agoStorable: Need more stack reserve on cygwin also
Reini Urban [Sun, 14 May 2017 20:28:21 +0000 (22:28 +0200)]
Storable: Need more stack reserve on cygwin also

Same stack quirks as on MSWin32.
cygwin64 cannot even do 32, try 40.

(cherry picked from commit c663e2126c5060f80eb973828a341606f210f671)

6 years agoStorable: fix cygwin stack probing
Reini Urban [Fri, 12 May 2017 07:49:38 +0000 (09:49 +0200)]
Storable: fix cygwin stack probing

don't set the PATH needed for other DLLs also.

(cherry picked from commit d0f8b62c3f9ffee9fa8397d4acdadbd695cc4839)

6 years agoStorable: Update to 3.05_12
Reini Urban [Wed, 19 Apr 2017 07:18:49 +0000 (09:18 +0200)]
Storable: Update to 3.05_12

enhance stack reserve from 8 to 16

(cherry picked from commit e344ff0826555342fe207a4a52bcdda4b00e2c44)

Conflicts:
Porting/Maintainers.pl
dist/Module-CoreList/lib/Module/CoreList.pm
dist/Storable/Storable.pm
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable: fix stacksize with shared libcperl
Reini Urban [Tue, 18 Apr 2017 08:39:29 +0000 (10:39 +0200)]
Storable: fix stacksize with shared libcperl

LD_LIBRARY_PATH=dist/Storable/../..
Interestingly only detected on Solaris, not elsewhere.

(cherry picked from commit 4fc1e35393d951b249e36e02f89ec8d0f9cd7537)

6 years agoStorable: fix wrong fake_tag check
Reini Urban [Thu, 30 Mar 2017 09:22:31 +0000 (11:22 +0200)]
Storable: fix wrong fake_tag check

coverity CID 165506. if (!sv) is always true. check fake_tag instead.

(cherry picked from commit 3cb71a68201936293a78ed93ca8049ee4cba5497)

6 years agoStorable: memory leak
Reini Urban [Thu, 30 Mar 2017 07:04:07 +0000 (09:04 +0200)]
Storable: memory leak

detected by coverity

(cherry picked from commit b60e26ff913f3ada34f57e79347e11d3872876c9)

6 years agoStorable 3.05_11: croak on sizes read > I32_MAX
Reini Urban [Wed, 29 Mar 2017 19:04:28 +0000 (21:04 +0200)]
Storable 3.05_11: croak on sizes read > I32_MAX

detected by coverity:
CID 165606 (#2 of 2): Untrusted value as argument (TAINTED_SCALAR)
146. tainted_data: Passing tainted variable size to a tainted sink.

(cherry picked from commit 735d9229a540d05f2d34f46ffea1e68aea9fbbc1)

Conflicts:
dist/Storable/Storable.pm

6 years agoStorable: simplify last_op_in_netorder
Reini Urban [Wed, 29 Mar 2017 19:52:30 +0000 (21:52 +0200)]
Storable: simplify last_op_in_netorder

remove dead code, detected by coverity

(cherry picked from commit f1e1f909cfd3e474a0b11f0200a3889b8ff2cc6f)

6 years agoStorable: protect from empty retrieve_vstring
Reini Urban [Wed, 29 Mar 2017 19:32:57 +0000 (21:32 +0200)]
Storable: protect from empty retrieve_vstring

empty sv detected by coverity

(cherry picked from commit 96c0b32bf6ab37f5e82494b79149680012dde49f)

6 years agoStorable: protect store_other error buf
Reini Urban [Wed, 29 Mar 2017 19:29:46 +0000 (21:29 +0200)]
Storable: protect store_other error buf

coverity warns about static buffer overflow.

(cherry picked from commit 74804347b8da42bc5b471646032c2e8d9903106f)

6 years agoStorable: Bump to 3.05_10
Reini Urban [Tue, 14 Mar 2017 09:05:24 +0000 (10:05 +0100)]
Storable: Bump to 3.05_10

No changes, synced cpan with CORE

(cherry picked from commit 0edca17dff085908bd7c3286ffabb3c0e9371706)

Conflicts:
Porting/Maintainers.pl
dist/Module-CoreList/lib/Module/CoreList.pm
dist/Storable/Storable.pm
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable: various core fixups: $PERL,libpth,getcwd
Reini Urban [Sun, 12 Mar 2017 11:28:31 +0000 (12:28 +0100)]
Storable: various core fixups: $PERL,libpth,getcwd

stacksize needs to run perl, not miniperl,
but the chdir broke $^X (a relative path).
Quote $^X only with whitespace.
Set LD_LIBRARY_PATH with a shared libperl.
Support a --core argument to stacksize.
Probe it twice.

(cherry picked from commit 0df5d8e463b9b5cfe14f9c235191fd3e5e4013a4)

6 years agoStorable: core Makefile.SH support
Reini Urban [Fri, 10 Mar 2017 09:59:53 +0000 (10:59 +0100)]
Storable: core Makefile.SH support

redo building Storable after perl was built,
with the probed stacksize.h values.
We can only produce stacksize.h with a PERL_EXE
so we have to do it twice.

TonyC:

 - this fixes the stack overflow iff the rebuild_storable target runs
   after storable is built, but there's nothing preventing
   lib/auto/Storable/Storable.so being built *after* rebuild_storable
   in a parallel build at this point.

 - It's also possible for both the lib/...Storable.so target and the
   rebuild_storable target to run at the same time, possibly
   corrupting the generated binary (check 4d106cc5 for ext/SDBM_File
   for example)

Conflicts:
.git-rr-cache
pod/perlcdelta.pod
win32/Makefile.ce

6 years agoStorable 3.05_09: compute stacksize
Reini Urban [Thu, 9 Mar 2017 08:49:31 +0000 (09:49 +0100)]
Storable 3.05_09: compute stacksize

(cherry picked from commit a10c78df8c03018ce50f0885bb6b6a5509d9e58f)

TonyC:
 - dist/Storable/t/recurse.t is still crashing on a stack overflow

Conflicts:
Porting/Maintainers.pl
dist/.gitignore
dist/Module-CoreList/lib/Module/CoreList.pm
dist/Storable/Storable.pm
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable 3.05_08: adjust MAX_DEPTH
Reini Urban [Wed, 8 Mar 2017 15:18:32 +0000 (16:18 +0100)]
Storable 3.05_08: adjust MAX_DEPTH

2000 is too large for DEBUGGING with clang++. It runs into stack overflow.
Seperate between c++ and c, debugging and non, 32bit and 64bit.

Tune the stack sizes for various variants.
New stack recursion limits:
64: c++ dbg: 1200   DEBUGGING + DEBUG_LEAKING_SCALAR non-threaded
    c   dbg: 3000
    c -O3:   34000 (tested: 34500)
32: c -O3:   30000 (tested: 32600)
    c   dbg: 750   (tested: 1500)
asan: 254

Note that the result has to be int, as the value is then right shifted by the
pre-processor, >> 1, for hashes (i.e. divide by 2).

TonyC:
 - Storable.o fails to build, but the offending code is removed in the
   next commit

(cherry picked from commit a7aff4921e16004c42e40914914e5f3320238e12)

Conflicts:
dist/Module-CoreList/lib/Module/CoreList.pm
dist/Storable/Storable.pm
dist/Storable/t/blessed.t
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable 3.05_07: update documentation from CPAN
Reini Urban [Sun, 5 Mar 2017 10:29:54 +0000 (11:29 +0100)]
Storable 3.05_07: update documentation from CPAN

from the CPAN version.

(cherry picked from commit 81259118dd8e16b10dfbdcfe1e2355bae507ac51)

Conflicts:
.git-rr-cache
dist/Storable/Storable.pm
pod/perlcdelta.pod

6 years agoStorable: improve recursion depth check
Reini Urban [Sun, 5 Mar 2017 10:09:01 +0000 (11:09 +0100)]
Storable: improve recursion depth check

Store each recursive SV and only ++depth when recursing
into this same SV, not nested into 2 levels, for performance reasons.
(We'd really need to store a hash, but this would be slow.)
So it only protects from the simpliest stack exhaustion attacks,
others still will segfault.
Decrease the max depth numbers: 2000 for RV and AV, 1000 for HV,
experimentally tested for normal stack sizes.

At least it doesnt falsely error with an arrayref nested into another
big array, as with the CPAN write_metadata_cache.
Check now also refs recursion into each other.

Closes #257.

(cherry picked from commit cd2b11a42ef9c6829960039382a06622d7248755)

Conflicts:
dist/Storable/Storable.pm
pod/perlcdelta.pod

6 years agoStorable: add testcase for #257
Reini Urban [Sat, 4 Mar 2017 11:42:36 +0000 (12:42 +0100)]
Storable: add testcase for #257

detected by CPAN,
wrong recursion warning with CPAN write_metadata_cache.
There's no recursion involved, just nesting a hash into a big
array will fail.

(cherry picked from commit 2804828cb8c402649cc89f1c40fda63932ccae44)

6 years agoFix rurban email address
Reini Urban [Tue, 28 Feb 2017 22:34:45 +0000 (23:34 +0100)]
Fix rurban email address

use the generic cpan.org

(cherry picked from commit 90875988463bbf4b10af59633e23a6a2b2a2cfbe)

TonyC:
 - at this point dist/Storable/t/recurse.t crashes with a stack
   overflow, presumably fixed by the later "tuning" commits

Conflicts:
.travis.yml
AUTHORS
Porting/do-conf-cperl-release
Porting/do-make-cperl-release
Porting/release_cperl.pod
appveyor.yml
cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm
cpan/CPAN-Meta/lib/CPAN/Meta.pm
cpan/Config-Perl-V/t/28_plv522c.t
cpan/Cpanel-JSON-XS/XS.pm
cpan/Scalar-List-Utils/lib/Sub/Util.pm
cpan/YAML-LibYAML/lib/YAML/XS.pod
dist/CPAN-Meta/lib/Parse/CPAN/Meta.pm
ext/Config/Makefile.PL
pod/cperl.pod
pod/perl.pod
t/porting/customized.dat

6 years agoStorable: Update to 3.05_03
Reini Urban [Mon, 30 Jan 2017 21:16:44 +0000 (22:16 +0100)]
Storable: Update to 3.05_03

Appveyor win64 fails to create nested hash.
Need to repro it on a failing machine. Maybe Win64
uses a much bigger stack for its threads. But 5000 should
still be doable, as other machines can do 22_000.

(cherry picked from commit 81786bf3f6be1f6326b588eca9ae3ccc4824b5a8)

Conflicts:
.git-rr-cache
Porting/Maintainers.pl
dist/Storable/Storable.pm
pod/perlcdelta.pod

6 years agoStorable: Update to 3.05_02
Reini Urban [Mon, 30 Jan 2017 16:52:24 +0000 (17:52 +0100)]
Storable: Update to 3.05_02

Protect against stack overflows with nested arrays and hashes
[cpan #97526]. This imposes a new limit to your nested structures,
but JSON::XS has a limit of 512. We use a max_depth of 3000 for the
typical stack limit of 8k.
You can still overflow the call stack with nested scalar refs.

(cherry picked from commit 63a5b7f922c2900e328ce97b57d0a54fbc763a98)

Conflicts:
.git-rr-cache
Porting/Maintainers.pl
dist/Storable/Storable.pm
pod/perlcdelta.pod

6 years agoStorable: Upgrade to 3.05 from CPAN
Reini Urban [Sun, 29 Jan 2017 11:43:18 +0000 (12:43 +0100)]
Storable: Upgrade to 3.05 from CPAN

See https://github.com/rurban/Storable/

(cherry picked from commit 17a1797c711ed6de48985b0746ae59282f634b12)

Conflicts:
Porting/Maintainers.pl
dist/Storable/Storable.pm
dist/Storable/Storable.xs
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable: re-indent from 8 hard tabs to soft 4
Reini Urban [Fri, 27 Jan 2017 23:10:17 +0000 (17:10 -0600)]
Storable: re-indent from 8 hard tabs to soft 4

(cherry picked from commit a5b8bb11df1a50b585a1b07965c860c234877ce3)

Conflicts:
dist/Storable/Storable.xs
t/porting/customized.dat

6 years agoStorable: skip LOBJECT on 32bit
Reini Urban [Fri, 27 Jan 2017 16:45:53 +0000 (10:45 -0600)]
Storable: skip LOBJECT on 32bit

croak there.  There is no way to store 64bit objects, and when reading them
we need to croak.  We check the len though (at least on little-endian, on
big-endian this is broken.)

(cherry picked from commit d6e38371a2997e9546cbf340148a41439091b3c2)

Conflicts:
.git-rr-cache
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable: fixup huge
Reini Urban [Thu, 26 Jan 2017 23:31:35 +0000 (17:31 -0600)]
Storable: fixup huge

followup to 67a5186ac1aee4b63 with 3.00c.
MBUF_XTEND and more internal sizes, esp. the dclone size,
needs to use long, not int.
Improve TRACEME to cut off printing overlong strings.

(cherry picked from commit d987f810b5f285b075103f58ce43e54d181643bc)

Conflicts:
pod/perlcdelta.pod
pod/perlcperl.pod
t/porting/customized.dat

6 years agoStorable: protect against classname len overflow
Reini Urban [Wed, 25 Jan 2017 17:27:07 +0000 (11:27 -0600)]
Storable: protect against classname len overflow

name lenghts can be max. I32 (hek_len), but are read from
system size integers. e.g. -1 you can cause a malloc fail => exit.

Even worse len > LG_BLESS didn't detect that so you could overwrite
the stack by malcrafted Storable files.
Found out by JD. RT #130635. No CVE since p5p believes local Storable
files are not exploitable.

(cherry picked from commit c82e80f6d88891738e2b5329723606b48347fa31)

Conflicts:
.git-rr-cache
Porting/Maintainers.pl
dist/Storable/Storable.xs
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable 3.04c: fix printf types
Reini Urban [Sat, 7 Jan 2017 08:01:29 +0000 (09:01 +0100)]
Storable 3.04c: fix printf types

esp. for 32bit use64bitint:
Storable.xs:2348:4: warning: shift count >= width of type [-Wshift-count-overflow]
                        STORE_PV_LEN((const char *)mg->mg_ptr, len

cast printf args to the right type.

(cherry picked from commit c08d0a10791ec59b04354a1fbd2ed07b3681c703)

Conflicts:
.git-rr-cache
dist/Storable/Storable.pm
t/porting/customized.dat

6 years agoStorable: Update to 3.02c
Reini Urban [Sun, 20 Nov 2016 17:06:45 +0000 (18:06 +0100)]
Storable:  Update to 3.02c

Fix -Wc++11-compat warnings

(cherry picked from commit 852424577630848b6ed6faef3f3a0396f2e91bb8)

Conflicts:
dist/Storable/Storable.pm
dist/Storable/Storable.xs
pod/perlcdelta.pod
t/porting/customized.dat

6 years agoStorable: fix -Wchar-subscripts
Reini Urban [Mon, 10 Oct 2016 10:14:49 +0000 (12:14 +0200)]
Storable: fix -Wchar-subscripts

array subscript is of type char. in DEBUGGING code only.

(cherry picked from commit 07af5b27a799f0b88a5368d81fd57c7643e2edff)

Conflicts:
t/porting/customized.dat

6 years agoStorable 3.01 security: detect CVE-2015-1592
Reini Urban [Thu, 15 Sep 2016 23:20:42 +0000 (01:20 +0200)]
Storable 3.01 security: detect CVE-2015-1592

warn and test against this published metasploit attack vector.
See GH #199

Conflicts:
dist/Storable/Storable.pm

TonyC:
 - backported parts of 17a1797 to make it compatible with blead
 - updated MANIFEST

6 years agoStorable: silence cast warnings
Reini Urban [Fri, 16 Sep 2016 10:01:48 +0000 (12:01 +0200)]
Storable: silence cast warnings

6 years agoStorable: comments
Reini Urban [Mon, 20 Jun 2016 06:29:27 +0000 (08:29 +0200)]
Storable: comments

6 years agoStorable: throw exception on huge values
Reini Urban [Wed, 4 Oct 2017 04:26:37 +0000 (15:26 +1100)]
Storable: throw exception on huge values

The Storable data format is incapable of representing lengths of 2**31 or
greater; and if you try, you can get segfaults or corrupt data or other fun
and games.

Though it would be undeniably good to fix this properly, this is just a
simple starting point: the limitation is documented, and an exception is
thrown when such data is encountered.

Signed-off-by: Reini Urban <rurban@cpanel.net>
Conflicts:
dist/Storable/Storable.pm
dist/Storable/Storable.xs

6 years agoRelease cperl-5.22.2
Reini Urban [Sun, 8 May 2016 18:28:51 +0000 (20:28 +0200)]
Release cperl-5.22.2

Conflicts:
INSTALL
META.json
dist/Module-CoreList/lib/Module/CoreList.pm
dist/Module-CoreList/lib/Module/CoreList/Utils.pm
pod/perlhist.pod
t/porting/customized.dat

TonyC:
 - this was largely a core commit, with a minor change to Storable.
   Only the change to Storable has been included.

Cherry-picked from 5d23481d9dc73edc8b59e3ad1ea9f7da164fcfd3

6 years agoStorable: fix win32, missing INT32_MAX
Reini Urban [Fri, 29 Apr 2016 10:26:47 +0000 (12:26 +0200)]
Storable: fix win32, missing INT32_MAX

6 years agoparser: expand tokenbuf from 256 to 1024
Reini Urban [Fri, 1 Apr 2016 07:42:41 +0000 (09:42 +0200)]
parser: expand tokenbuf from 256 to 1024

This should speed up parsing,
and changes the "Identifier too long" limitation from max 256 to 1024.
See [cperl #124]

TonyC:
 - this was largely a core change, with an incidental change to Storable,
   only the Storable change has been included for compatibility with cperl

6 years agoStorable 3.00: u64 strings, arrays and hashes >2G
Reini Urban [Tue, 29 Mar 2016 15:50:09 +0000 (17:50 +0200)]
Storable 3.00: u64 strings, arrays and hashes >2G

via a new LOBJECT tag. This is for 32bit systems and lengths
between 2GB and 4GB (I32-U32), and 64bit (>I32).
Use SSize_t array and hash lengths, see [cperl #123].

Even for hashes, which we cannot iterate over.
This is a upstream limitation in the HvAUX struct and API.
We can store >2G keys though, which is fully supported
in subsequent cperl commits for #123, but not perl5 upstream.

Add several helper functions for strings and hash entries,
removed a lot of duplicate code.

Reformat consistently (tabs: 8)

Modernize:
* get rid of main'dump
* get rid of *FILE typeglob, replace with lexical filehandle
* fix parallel tests, use unique filenames.
* fixed many instances of 2arg open,
* keep backcompat default handling for XS functions, handle the flag
  default there.
* remove default $Storable::flags settings in the tests
* fix some too short I32 len types in the XS

Conflicts:
dist/Storable/Storable.pm
dist/Storable/Storable.xs
dist/Storable/t/attach_errors.t
dist/Storable/t/blessed.t
dist/Storable/t/destroy.t
dist/Storable/t/testlib.pl

6 years agoStorable: throw exception on huge values
Aaron Crane [Fri, 18 Mar 2016 15:22:12 +0000 (15:22 +0000)]
Storable: throw exception on huge values

The Storable data format is incapable of representing lengths of 2**31 or
greater; and if you try, you can get segfaults or corrupt data or other fun
and games.

Though it would be undeniably good to fix this properly, this is just a
simple starting point: the limitation is documented, and an exception is
thrown when such data is encountered.

Signed-off-by: Reini Urban <rurban@cpanel.net>
Conflicts:
dist/Storable/Storable.pm
dist/Storable/Storable.xs

6 years agoStorable: document, reformat and fix for DEBUGGING
Reini Urban [Tue, 29 Mar 2016 12:59:02 +0000 (14:59 +0200)]
Storable: document, reformat and fix for DEBUGGING

fix t/blessed.t: we do try to auto-load modules
for bless, and avoid regressions. One security flag
BLESS_OK is enough to disable this.

fix all DEBUGGING 64bit warnings, with TRACEME.

add asserts from blead perl 5.24.

update hints/linux.pl for the known gcc -O3 bug.
Not repro with gcc 4 nor clang.

fix documentation: SECURITY WARNING, Large data
on 64-bit platforms

Conflicts:
dist/Storable/Storable.xs
dist/Storable/t/blessed.t

Cherry-picked from fe00be04fba2ec29f6d0c897a21d0c2771954def

6 years agocPanel Storable 2.53_03: don't bless [security]
Todd Rinaldo [Tue, 3 Oct 2017 01:49:07 +0000 (12:49 +1100)]
cPanel Storable 2.53_03: don't bless [security]

Optional flags arg to disable bless|tie on retrieve/thaw

Signed-off-by: Reini Urban <rurban@cpanel.net>
and added documentation, reformat, compute CAN_FLOCK at compile-time.
See [cperl #120]

TonyC:

 - removed pod/perlcdelta.pod changes
 - this commit removed auto-loading modules for overloading, which
   was reinstated in a later commit.

cherry-picked from 04b58ce1b1c391d04efb2c0a3da108603b8cafc6

6 years agoStorable: bump to 2.53_02
Reini Urban [Thu, 24 Mar 2016 16:49:07 +0000 (17:49 +0100)]
Storable: bump to 2.53_02

enable STORABLE_DEBUGME with -DEBUGGING.
add split debugging trace messages.
improve canonical store_hash pre-allocation.

Conflicts:
dist/Storable/Storable.pm
dist/Storable/Storable.xs
dist/Storable/t/restrict.t

6 years agofix perl #132630, dont try to fbm match past end of string
Yves Orton [Wed, 7 Feb 2018 22:00:18 +0000 (23:00 +0100)]
fix perl #132630, dont try to fbm match past end of string

6 years agoperlapi: Rmv nonapplicable text
Karl Williamson [Sun, 4 Feb 2018 05:16:39 +0000 (22:16 -0700)]
perlapi: Rmv nonapplicable text

6 years agoregcomp.c: Fix comment
Karl Williamson [Sun, 4 Feb 2018 05:15:51 +0000 (22:15 -0700)]
regcomp.c: Fix comment

6 years agoAdd uvchr_to_utf8_flags_msgs()
Karl Williamson [Sun, 4 Feb 2018 05:14:22 +0000 (22:14 -0700)]
Add uvchr_to_utf8_flags_msgs()

This is propmpted by Encode's needs.  When called with the proper
parameter, it returns any warnings instead of displaying them directly.

6 years agoAPItest:t/utf8_warn_base.pl: Clarify some comments
Karl Williamson [Sun, 4 Feb 2018 05:09:28 +0000 (22:09 -0700)]
APItest:t/utf8_warn_base.pl: Clarify some comments

6 years agoAPItest:t/utf8_warn_base.pl: Move a variable outside sub()
Karl Williamson [Sun, 4 Feb 2018 05:06:35 +0000 (22:06 -0700)]
APItest:t/utf8_warn_base.pl: Move a variable outside sub()

This is in preparation for a future commit which will want to refer to
this variable independently.

6 years agoAPItest:t/utf8_warn_base.pl; Fix 'ok' tests
Karl Williamson [Fri, 2 Feb 2018 18:38:29 +0000 (11:38 -0700)]
APItest:t/utf8_warn_base.pl; Fix 'ok' tests

This was putting the condition for the ok in a string, which always
succeeds

6 years agoutf8.c: Extract code into separate function
Karl Williamson [Fri, 2 Feb 2018 17:43:33 +0000 (10:43 -0700)]
utf8.c: Extract code into separate function

This is in preparation for the next commit which will use this code in
multiple places

6 years agofix tr/// Deparse tests under EBCDIC
David Mitchell [Wed, 7 Feb 2018 10:34:02 +0000 (10:34 +0000)]
fix tr/// Deparse tests under EBCDIC

Some tests I recently added had A-Z in the replacement charlist, which
under EBCDIC gets deparsed as A-IJ-RS-Z, so original and deparsed don't
match.

Ideally the deparsing could be smart enough to coalesce those ranges,
but for now I've just changed the range to A-I which deparses ok on both
ASCII and EBCDIC.

The point of the test is for when there are more replacement chars than
search chars, and in this case A-I works just as well as A-Z.

Spotted by Karl.

6 years agolocale.c: Use same form of macro name
Karl Williamson [Tue, 6 Feb 2018 05:14:48 +0000 (22:14 -0700)]
locale.c: Use same form of macro name

This macro has synonyms; use the one prevailing in the adjacent code, so
that future maintainers think there is something strange going on that
is needed to investigate, only to find that nothing was going on.

6 years agoperldelta for bb4e4c3869d9
Tony Cook [Mon, 5 Feb 2018 23:57:26 +0000 (10:57 +1100)]
perldelta for bb4e4c3869d9

6 years ago(perl #125351) abort parsing if parse errors happen in a sub lex
Tony Cook [Tue, 30 Jan 2018 05:40:53 +0000 (16:40 +1100)]
(perl #125351) abort parsing if parse errors happen in a sub lex

We've had a few reports of segmentation faults and other misbehaviour
when sub-parsing, such as within interpolated expressions, fails.

This change aborts compilation if anything complex enough to not be
parsed by the lexer is compiled in a sub-parse *and* an error
occurs within the sub-parse.

An earlier version of this patch failed on simpler expressions,
which caused many test failures, which this version doesn't (which may
just mean we need more tests...)

6 years ago[perl #132799] Fix goto within block within expr
Father Chrysostomos [Mon, 5 Feb 2018 06:50:15 +0000 (22:50 -0800)]
[perl #132799] Fix goto within block within expr

When goto looks for a label, it builds up a list of ops to enter.  But
it begins its search a little too far out relative to the ‘goto’.
Hence, the first op gets skipped.

In 6d90e983841, I forbade same cases of inward goto-into-expression to
avoid stack corruption and crashes.  I did this by pushing a marker
on to the list of ops to enter, indicating that an error should be
thrown instead.

Because goto starts the search too far up the context stack, it would
sometimes end up looking inside an expression, which would cause the
first op on the entry list to be such a marker, meaning that the next
item, which should have been skipped, would not be.

That could really screw up the context stack for cases like:

    my $e = eval { goto label; label: }

because the entry list would be:

    <croak-marker> entertry

instead of the previous:

    entertry

Hence, entertry (which enters eval{}) would be executed from *within*
the eval, causing the exit of the eval to leave an eval on the context
stack.  Crashes ensued.

This commit fixes it by checking whether we have moved past the begin-
ning of the list of entry ops before pushing a croak-marker on to it.

Goto’s implementation is really complex, and always has been.  It
could be greatly simplified now thot ops have parent pointers.  But
that should wait for another developement cycle.

6 years agoAPItest: Add tests for utf8_to_bytes()
Karl Williamson [Mon, 5 Feb 2018 04:47:09 +0000 (21:47 -0700)]
APItest: Add tests for utf8_to_bytes()

6 years agoAPItest:t/utf8_setup.pl: Display printables as themselves
Karl Williamson [Mon, 5 Feb 2018 04:44:17 +0000 (21:44 -0700)]
APItest:t/utf8_setup.pl: Display printables as themselves

Instead of the harder to read \xXX

6 years agoregcomp.c: Comment, white-space only
Karl Williamson [Mon, 5 Feb 2018 02:15:00 +0000 (19:15 -0700)]
regcomp.c: Comment, white-space only

6 years agoregcomp.c: Simplify handling of varying loop increments
Karl Williamson [Mon, 5 Feb 2018 01:48:26 +0000 (18:48 -0700)]
regcomp.c: Simplify handling of varying loop increments

Prior to this commit, this loop added 1 to a variable each iteration as
part of the for(;;).  This created some issues for the few cases where
that increment should be something else.

Now, the addition is removed from the for(;;), and defaults to 1, so
that the code inside doesn't have to account for an automatic 1 in the
for().

6 years agoDisable CV-in-stash optimization
Father Chrysostomos [Sun, 4 Feb 2018 19:13:56 +0000 (11:13 -0800)]
Disable CV-in-stash optimization

outside of the main package.

Instead of actually reverting to the previous logic that excluded
packages other that main as a side effect of the logic being
faulty, this time I am checking for the main package explicitly.

6 years agoregcomp.c: Clarify comment
Karl Williamson [Sat, 3 Feb 2018 17:29:33 +0000 (10:29 -0700)]
regcomp.c: Clarify comment

6 years agoregcomp.c: Pack EXACTish nodes more fully
Karl Williamson [Sat, 3 Feb 2018 17:25:31 +0000 (10:25 -0700)]
regcomp.c: Pack EXACTish nodes more fully

Prior to this commit, nodes that are to match a string exactly, or
possibly case insensitively used only half the potential space available
(that being limited by the length field which is a U8).  (The optimizer
might later pack some together to make a larger node.)  Talking it over
with Yves, we suspect that this is a relic of an earlier time.  It makes
more sense to have longer nodes when possible to lower overhead in
the matching engine.

6 years agoSkip t/op/state.t tests that need attributes under miniperl
Hugo van der Sanden [Sat, 3 Feb 2018 16:04:08 +0000 (16:04 +0000)]
Skip t/op/state.t tests that need attributes under miniperl

6 years ago[perl #115814] skip layer test under miniperl
Hugo van der Sanden [Sat, 3 Feb 2018 10:43:11 +0000 (10:43 +0000)]
[perl #115814] skip layer test under miniperl

6 years agoMark new function utf8n_to_uvchr_msgs() as experimental
Karl Williamson [Fri, 2 Feb 2018 04:53:53 +0000 (21:53 -0700)]
Mark new function utf8n_to_uvchr_msgs() as experimental

This function was written specifically for Encode's needs.  My intent is
to eventually make it publicly usable, but since it's new, we should
give some time for it to prove itself.

6 years agoSpeed up finding non-UTF8 EXACTFish initial matches
Karl Williamson [Fri, 2 Feb 2018 03:49:03 +0000 (20:49 -0700)]
Speed up finding non-UTF8 EXACTFish initial matches

find_byclass() is used to scan through a target string looking for
something that matches a particular class.  This commit speeds that up
for patterns of the /foo/i type, where neither the target string nor
the pattern are UTF-8.

More precisely, it speeds up only finding the first byte of 'foo'
in the string.  The actual matching speed remains the same, once that
initial character that is a potential match is found.

But finding that first character is sped up immensely by this commit.

It does this by using memchr() when the character is caseless.  For
example in the pattern /:abcde/i, the colon is first, and is caseless.
On my system memchr is extremely fast, so the numbers below for this
case may not be as good on other systems.

And when the first character is cased, such as in /abcde/i, it uses the
techniques added in 2813d4adc971fbaa124b5322d4bccaa73e9df8e2 for the
ANYOFM regnode.  In both ASCII and EBCDIC machines, the case folds of
the cased letters are almost all of the form that these techniques work
on.  There are no tests in our current test suite that don't have this
form.  However, /il (locale) matching may very well violate this, and
will use the per-byte scheme that has been in effect until this commit.

The numbers below are for finding the first letter after a long string
that doesn't include that character.  Doing this isolates the speed up
attributable to this commit from ovehead.

The only downsides of this commit are that on some systems memchr() may
introduce function call overhead that won't pay off if the next
occurrence of the character is close by; and in the other case, a single
extra conditional is required to determine if there is at least a word's
worth of data to look at, plus some masking, shifting, and arithmetic
instructions associated with that conditional.  A static function is
called, so there may or may not be function call overhead, depending on
the compiler optimizer.

Key:
    Ir   Instruction read
    Dr   Data read
    Dw   Data write
    COND conditional branches
    IND  indirect branches

The numbers represent raw counts per loop iteration.

caseless first letter
('b' x 10000) . ':' =~ /:a/i

          blead    fast Ratio %
       -------- ------- -------
    Ir  72109.0  4819.0  1496.3
    Dr  20608.0  1237.5  1665.3
    Dw  10409.0   409.5  2541.9
  COND  20376.0   702.0  2902.6
   IND     15.0    16.0    93.8

cased first letter
('b' x 10000) . 'a' =~ /A/i

          blead    fast Ratio %
       -------- ------- -------
    Ir 103074.0 25704.6   401.0
    Dr  20896.5  2164.9   965.2
    Dw  10587.5   601.9  1759.0
  COND  30516.0  3036.2  1005.1
   IND     22.0    22.0   100.0

6 years agoregexec.c: Don't retest the same byte immediately
Karl Williamson [Fri, 2 Feb 2018 02:42:50 +0000 (19:42 -0700)]
regexec.c: Don't retest the same byte immediately

In this macro, COND has just returned true for the given byte.  We then
need to test that the rest of the relevant portion of the input string
and pattern match.  But before this commit, we started at the byte we
already know the answer for.  Change to test starting one position over.

6 years ago'if' module: clarify documentation and test more thoroughly.
James E Keenan [Tue, 23 Jan 2018 15:46:32 +0000 (10:46 -0500)]
'if' module: clarify documentation and test more thoroughly.

The documentation for 'if' made certain claims about the need to quote or not
quote a module name preceding a "fat arrow" ('=>') operator.  These claims
were shown to be unfounded in most cases when "use strict 'subs'" was in
effect.

In the course of writing better documentation, it was observed that the "no
if" case was very under-tested, poorly documented and hence poorly understood.
Hence, more tests have been added and the documentation has been extensively
revised.  However, there have been no changes in source code or functionality.

Make porting/podcheck.t happy.  Compensate for functions not available on
older perls.  Documentation touch-ups suggested by sisyphus.

For:  RT # 132732.

6 years agopp_warn: use MEXTEND rather than EXTEND
David Mitchell [Wed, 20 Dec 2017 13:07:46 +0000 (13:07 +0000)]
pp_warn: use MEXTEND rather than EXTEND

RT #132602

6 years agolocale.c: Do savepv() ASAP
Karl Williamson [Wed, 17 Jan 2018 20:54:27 +0000 (13:54 -0700)]
locale.c: Do savepv() ASAP

When this code is called on a threaded perl, it's possible that another
thread could zap the setlocale return buffer, if it's not reentrant.  I
suspect we would have seen this more often if that was the case, but
this commit improves things by doing the save immediately, reducing the
unsafe interval.

6 years agoPOSIX::localconv(): Prefer localeconv_l()
Karl Williamson [Wed, 17 Jan 2018 20:32:32 +0000 (13:32 -0700)]
POSIX::localconv(): Prefer localeconv_l()

This is a thread-safe version of localeconv(), so use it under threads.

6 years agoPOSIX.xs: Add mutex around localeconv()
Karl Williamson [Wed, 17 Jan 2018 18:22:02 +0000 (11:22 -0700)]
POSIX.xs: Add mutex around localeconv()

If another thread calls localeconv(), it can destroy the returned
buffer.  This adds a mutex around this call; the only other place in the
core that calls it already has this mutex, so they now are thread-safe.

6 years agolocale.c: Use %z for displaying Size_t operands
Karl Williamson [Wed, 31 Jan 2018 13:51:17 +0000 (06:51 -0700)]
locale.c: Use %z for displaying Size_t operands

This should fix [perl #132701]

6 years agoPOSIX.xs: Prefer mbrtowc() over mbtowc()
Karl Williamson [Thu, 11 Jan 2018 05:35:12 +0000 (22:35 -0700)]
POSIX.xs: Prefer mbrtowc() over mbtowc()

mbrtowc is reentrant, so use it on threaded perls if available when
POSIX::mbtowc() is called.

6 years agoPOSIX.xs: Prefer mbrlen() over mblen()
Karl Williamson [Thu, 11 Jan 2018 05:28:34 +0000 (22:28 -0700)]
POSIX.xs: Prefer mbrlen() over mblen()

mbrlen is reentrant, so use it on threaded perls if available when
POSIX::mblen() is called.

6 years agolocale.c: Avoid localeconv()
Karl Williamson [Sat, 6 Jan 2018 21:24:30 +0000 (14:24 -0700)]
locale.c: Avoid localeconv()

my_langinfo() is a recently added function which presents a better API
than localeconv, and returns the needed information here, and is easier
to make thread-safe.

6 years agolocale.c: White-space only
Karl Williamson [Tue, 9 Jan 2018 00:37:15 +0000 (17:37 -0700)]
locale.c: White-space only

This indents all this code, with no other changes, in preparation for a
future commit which will add a block around it.

6 years agolocale.c: Remove branch to label
Karl Williamson [Sun, 7 Jan 2018 22:58:52 +0000 (15:58 -0700)]
locale.c: Remove branch to label

The code at this label was branched to because it contained common
cleanup code.  But now that code is in a function, so the cleanup call
is trivial, so just skip this intermediate label.

6 years agolocale.c: Extract duplicated code into subroutines
Karl Williamson [Sat, 6 Jan 2018 19:42:35 +0000 (12:42 -0700)]
locale.c: Extract duplicated code into subroutines

These two paradigms are each repeated in 4 places.  Make into two
subroutines

6 years agolocale.c: Prefer mbrtowc(), as its reentrant
Karl Williamson [Sat, 6 Jan 2018 04:41:27 +0000 (21:41 -0700)]
locale.c: Prefer mbrtowc(), as its reentrant

If it's available and this is a threaded build, it's preferred.

6 years agolocale.c: White-space only
Karl Williamson [Sun, 7 Jan 2018 22:43:01 +0000 (15:43 -0700)]
locale.c: White-space only

Indent to correspond with new block from previous commit

6 years agolocale.c: Revamp finding if locale is UTF-8
Karl Williamson [Fri, 5 Jan 2018 21:09:40 +0000 (14:09 -0700)]
locale.c: Revamp finding if locale is UTF-8

This changes how this functionality works for the LC_CTYPE locale.  On
systems that have nl_langinfo() one can get a "definitive" answer from
just that.  Otherwise (or if that doesn't return properly) one can use
mbtowc() to check if the UTF-8 byte sequence for the Unicode REPLACEMENT
CHARACTER actually is considered to be that code point.  This is also
"definitive".  If the maximum byte string length for a character is too
short to handle all Unicode UTF-8, we know without further checking that
this isn't a UTF-8 locale, so can avoid the mbtowc check.

It turns out, from testing, that some locales are labelled UTF-8 by
nl_langinfo even though they depart from that at times.  Similarly for
mbtowc().  Perl assumes that a locale doesn't depart from this, and uses
its internal rules that it knows are UTF-8.  A future commit will warn
when this happens.

6 years agoChange some "shouldn't happen" failures into panics
Karl Williamson [Fri, 5 Jan 2018 18:35:00 +0000 (11:35 -0700)]
Change some "shouldn't happen" failures into panics

If the system is so broken that these libc calls are failing, soldiering
on won't lead to sane results.

THis rewords some existing panics, and adds the errno to the output for
all of them.

6 years agoForbid 'pig' locale
Karl Williamson [Sun, 28 Jan 2018 21:55:31 +0000 (14:55 -0700)]
Forbid 'pig' locale

This is a toy locale found on some systems, which isn't fully
implemented, and if one tries to switch to it can cause failures.

6 years agoAvoid changing locale when finding radix char
Karl Williamson [Thu, 18 Jan 2018 23:20:02 +0000 (16:20 -0700)]
Avoid changing locale when finding radix char

On systems that have the POSIX 2008 operations, including
nl_langinfo_l(), this commit causes them to not have to actually change
the locale when determining what the decimal point character is.

The locale may have to change during the printing/reading of numbers,
but eventually we can use sprintf_l(), if available, to avoid that too.

6 years agoPerl_sv_2pv_flags: Potentially avoid work
Karl Williamson [Thu, 18 Jan 2018 22:56:33 +0000 (15:56 -0700)]
Perl_sv_2pv_flags: Potentially avoid work

By using a macro that is private to the core, this code can avoid
thinking it has to deal with a non-dot radix character, as even if we
are using the locale radix, that is often a dot.

6 years agonumeric.c: Remove duplicate PERL_ARGS_ASSERT
Karl Williamson [Thu, 18 Jan 2018 22:53:42 +0000 (15:53 -0700)]
numeric.c: Remove duplicate PERL_ARGS_ASSERT

By moving the call to one instance of this macro, the other can be
removed.

6 years agolocale.c: White-space only
Karl Williamson [Thu, 18 Jan 2018 22:52:50 +0000 (15:52 -0700)]
locale.c: White-space only

Outdent to compensate for previous patch removing several blocks

6 years agoKeep PL_numeric_radix_sv always set
Karl Williamson [Thu, 18 Jan 2018 22:45:19 +0000 (15:45 -0700)]
Keep PL_numeric_radix_sv always set

Previously this was removed if the radix was dot.  By keeping it set to
a dot, we simplify some code, removing some branches.

6 years agolocale.c: Replace by function that does the same thing
Karl Williamson [Thu, 18 Jan 2018 22:32:45 +0000 (15:32 -0700)]
locale.c: Replace by function that does the same thing

This logic occurs often enough that a function has been created to do
it.  So use that.

6 years agoPOSIX::localeconv() Use new fcn; avoid recalcs
Karl Williamson [Wed, 17 Jan 2018 19:40:40 +0000 (12:40 -0700)]
POSIX::localeconv() Use new fcn; avoid recalcs

This calls strlen() once, instead of passing 0 to the the subsidiary
functions which causes them to call it each time.  It also uses the new
function is_utf8_non_invariant_string() instead of doing here what that
function does.

6 years agoPOSIX.xs: White space only
Karl Williamson [Wed, 17 Jan 2018 18:16:15 +0000 (11:16 -0700)]
POSIX.xs: White space only

Vertically align for readability

6 years agolocale.c: Move some mutex ops
Karl Williamson [Wed, 17 Jan 2018 18:07:42 +0000 (11:07 -0700)]
locale.c: Move some mutex ops

A future commit will add a mutex, and create the convention that this
mutex if used in combination with the new one always be tried after the
new one is in effect, in order to prevent the possibility of deadlock.
Do it now, before the new one gets added.

This also adds some comments about the reason for this mutex.

6 years agolocale.c: White-space only
Karl Williamson [Wed, 17 Jan 2018 17:12:30 +0000 (10:12 -0700)]
locale.c: White-space only

Indent code to account for previous commits adding some blocks

6 years agolocale.c: Use macro instead of its expansion
Karl Williamson [Wed, 17 Jan 2018 15:27:04 +0000 (08:27 -0700)]
locale.c: Use macro instead of its expansion

This macro in a future commit will become more complex.

6 years agolocale.c: Do common task in one place
Karl Williamson [Wed, 17 Jan 2018 05:09:27 +0000 (22:09 -0700)]
locale.c: Do common task in one place

This function in some cases may need to temporarily switch the
LC_NUMERIC code.  Instead of repeating the logic to determine if this is
needed, do it once.

6 years agoPOSIX.xs: Keep locale change to minimum span
Karl Williamson [Wed, 17 Jan 2018 00:38:45 +0000 (17:38 -0700)]
POSIX.xs: Keep locale change to minimum span

Move the restore to as close to the save as possible so that the locale
is in an unstable state for as short a time as possible.

6 years agoPOSIX::strftime: Add better fallback about UTF-8
Karl Williamson [Wed, 17 Jan 2018 20:24:46 +0000 (13:24 -0700)]
POSIX::strftime: Add better fallback about UTF-8

If the function returns a valid string that isn't completely UTF-8
invariant, the function assumes it is UTF-8 if we are in a UTF-8 locale.
This works, but in the unlikely event that the system has no LC_TIME, we
can't tesll if it is in a UTF-8 locale.  As a better fallback position,
this commit adds the check that there is just a single  script of the
time string, adding a measure of reassurance that out call that it is
UTF-8 is correct.

This is unlikely to be used, but now that there is a function to call
that determines if this is a script run, it's easy to add, and unlikely
to actually get compiled.

6 years agogrok_numeric_radix(): Avoid recalculating
Karl Williamson [Wed, 17 Jan 2018 20:18:50 +0000 (13:18 -0700)]
grok_numeric_radix(): Avoid recalculating

This function just determined that we are in the scope of 'use locale',
hence the underlying radix character should be used.  This commit
changes to use the macro that directly does that; previously the macro
that redundantly looks at if we are in the scope was used.

6 years agosv_vcatpvfn_flags() Balance LC_NUMERIC changes/restores
Karl Williamson [Wed, 17 Jan 2018 20:00:44 +0000 (13:00 -0700)]
sv_vcatpvfn_flags() Balance LC_NUMERIC changes/restores

Prior to this commit, the restore for LC_NUMERIC was getting called even
if there were no corresponding store.  Change so they are balanced; a
future commit will require this.