This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years agoAdd switch_to_globale_locale()
Karl Williamson [Fri, 16 Feb 2018 05:44:24 +0000 (22:44 -0700)]
Add switch_to_globale_locale()

This new API function is for use in applications that call alien library
routines that are expecting the old pre-POSIX 2008 locale functionality,
namely a single global locale accessible via setlocale().

This function converts the calling thread to use that global locale, if
not already there.

6 years agoRevise sync_locale() for safe multi-threaded operation
Karl Williamson [Fri, 16 Feb 2018 04:25:33 +0000 (21:25 -0700)]
Revise sync_locale() for safe multi-threaded operation

This function now returns a boolean, and does not want an aTHX
parameter.  There should be no impact on code that uses the macro form
to call it.

6 years agoperl.h: Add, revise some locale debugging info
Karl Williamson [Thu, 15 Feb 2018 04:28:51 +0000 (21:28 -0700)]
perl.h: Add, revise some locale debugging info

6 years agolib/locale_threads.t: Add safe thread test
Karl Williamson [Mon, 5 Feb 2018 19:32:41 +0000 (12:32 -0700)]
lib/locale_threads.t: Add safe thread test

6 years agoAdd thread-safe locale handling
Karl Williamson [Tue, 6 Feb 2018 05:11:51 +0000 (22:11 -0700)]
Add thread-safe locale handling

This (large) commit allows locales to be used in threaded perls on
platforms that support it.  This includes recent Windows and Posix 2008
ones.

6 years agoperl.h: Add debugging statements for mutex ops
Karl Williamson [Tue, 13 Feb 2018 23:53:43 +0000 (16:53 -0700)]
perl.h: Add debugging statements for mutex ops

6 years agoLatch LC_NUMERIC during critical sections
Karl Williamson [Tue, 13 Feb 2018 20:12:50 +0000 (13:12 -0700)]
Latch LC_NUMERIC during critical sections

It is possible for operations on threaded perls which don't 'use locale'
to still change the locale.  This happens when calling
POSIX::localeconv() and I18N::Langinfo(), and in earlier perls, it can
happen for other operations when perl has been initialized with the
environment causing the various locale categories to not have a uniform
locale.

This commit causes the areas where the locale for this category should
predictably be in one or the other state to be a critical section where
another thread can't interrupt and change it.  This is a separate
mutex, so that only these particular operations will be held up.

6 years agoMake new_numeric() static
Karl Williamson [Tue, 6 Feb 2018 04:52:54 +0000 (21:52 -0700)]
Make new_numeric() static

This core-only function is now used only in one file.

6 years agovutil.c: Revise locale version handling
Karl Williamson [Tue, 13 Feb 2018 19:44:02 +0000 (12:44 -0700)]
vutil.c: Revise locale version handling

This can be called from applications that have changed the locale behind
perl's back.  Prior to this commit, the code kind of assumed that some
things weren't broken, and that it should update perl's records to
correspond with the status of things.  But this may be an intermediate
state, and assuming perl should know about it is assuming too much.  We
might update perl, and the application restores the state, and control
gets transferred back in the wrong state.  So simply change the locale
to what it needs to be, if necessary, and change back.

This change needs to reported upstream to 'version'

6 years agoAdd Perl_setlocale()
Karl Williamson [Fri, 16 Feb 2018 21:13:19 +0000 (14:13 -0700)]
Add Perl_setlocale()

khw could not find any modules on CPAN that correctly use the C library
function setlocale().  (The very few that do try, do not use it
correctly, looking at the return value incorrectly, so they are broken.)
This analysis does not include modules that call non-Perl libaries that
may call setlocale().

And, a future commit will render the setlocale() function useless in
some configurations on some platforms.

So this commit adds Perl_setlocale(), for XS code to call, and which is
always effective, but it should not be used to alter the locale except
on platforms where the predefined variable ${^SAFE_LOCALES} evaluates to
1.

This function is also what POSIX::setlocale() calls to do the real work.

6 years agoperldelta for dTHX_DEBUGGING
Karl Williamson [Sun, 18 Feb 2018 18:40:41 +0000 (11:40 -0700)]
perldelta for dTHX_DEBUGGING

This documents the results of commit
2d17fb746d82c8098ef8cf0dee7d11f3844294a5

6 years agolocale.c: Add critical section
Karl Williamson [Thu, 15 Feb 2018 12:41:51 +0000 (05:41 -0700)]
locale.c: Add critical section

This code should be protected from another thread doing the same thing
nearly simultaneously, so that the static buffer doesn't get zapped in
this system call.

6 years agolocale.c: Generalize errno handling
Karl Williamson [Thu, 15 Feb 2018 11:55:49 +0000 (04:55 -0700)]
locale.c: Generalize errno handling

This file had been using just errno, instead of the more general macros
that can handle vax errnos as well.

6 years agolocale.c: Change some DEBUG_L to DEBUG_Lv
Karl Williamson [Thu, 15 Feb 2018 11:49:15 +0000 (04:49 -0700)]
locale.c: Change some DEBUG_L to DEBUG_Lv

These are better to display only when verbose is specified.

6 years agolocale.c: Suppress some compiler warnings
Karl Williamson [Thu, 15 Feb 2018 11:45:24 +0000 (04:45 -0700)]
locale.c: Suppress some compiler warnings

Cast these %.s precision specifiers to int.

6 years agoperlapi: Add a caution about Perl_langinfo()
Karl Williamson [Thu, 15 Feb 2018 11:42:06 +0000 (04:42 -0700)]
perlapi: Add a caution about Perl_langinfo()

6 years agolocale.c: Add debugging info
Karl Williamson [Tue, 6 Feb 2018 17:32:07 +0000 (10:32 -0700)]
locale.c: Add debugging info

This adds some information to a debugging statement, but mostly it adds
an audit of the utf8ness cache structure, invoked under -DLv.

6 years agoAdd ${^SAFE_LOCALES}
Karl Williamson [Thu, 15 Feb 2018 04:15:40 +0000 (21:15 -0700)]
Add ${^SAFE_LOCALES}

This read-only variable returns a boolean as to whether it is safe to
use locales in this perl.  Without threads it returns 1; when a future
commit adds thread-safe locale handling, it will also return 1 if that
is enabled.

6 years agoAdd information to warning msgs
Karl Williamson [Thu, 15 Feb 2018 05:43:51 +0000 (22:43 -0700)]
Add information to warning msgs

If we have nl_langinfo, this adds the codeset it returns to the messages
generated when there are anomalies in locales that are coming into
effect

6 years agolocale.c: Add comments, clarify others
Karl Williamson [Thu, 15 Feb 2018 12:24:02 +0000 (05:24 -0700)]
locale.c: Add comments, clarify others

6 years agolocale.c: White-space only
Karl Williamson [Thu, 15 Feb 2018 05:39:47 +0000 (22:39 -0700)]
locale.c: White-space only

This indents properly because of changes in the previous commit

6 years agolocale.c: Check for anomalies in UTF-8 locales
Karl Williamson [Thu, 15 Feb 2018 05:09:13 +0000 (22:09 -0700)]
locale.c: Check for anomalies in UTF-8 locales

Perl has, for some releases now, checked for anomalies in non-UTF-8
locales and raised warnings if any are found when such a locale actually
gets used.  This came about because it turns out that vendors have
defective locale definitions (that Perl has no control over, besides
reporting them as bugs to the proper places).

I was surprised to stumble across UTF-8 locales that don't adhere
strictly to Unicode, and so this commit now checks for such things and
raises an appropriate message.

Some of this is understandable because Turkish and related languages
have a locale-dependent exemption for them in the Unicode standard, but
others are simply defective locale definitions.

Perl will use the standard Unicode rules, but the user is now warned
that these aren't what the locale specified.

An example is that there are some UTF-8 locales where the common
punctuation characters like ",", "$" aren't marked as punctuation.

6 years agolocale.c: Rmv unnecessary locale toggle
Karl Williamson [Thu, 15 Feb 2018 04:40:24 +0000 (21:40 -0700)]
locale.c: Rmv unnecessary locale toggle

I don't know why this code thought it needed to change to the C locale
for LC_CTYPE, in order to output a fully formed warning message, and
then to switch back.  So remove the toggles.

6 years agoperl.h: Add dTHX_DEBUGGING
Karl Williamson [Tue, 6 Feb 2018 05:01:35 +0000 (22:01 -0700)]
perl.h: Add dTHX_DEBUGGING

which is a NOOP except on DEBUGGING builds

6 years agoExtUtils::ParseXS/lib/perlxs.pod: Nits
Karl Williamson [Tue, 29 Aug 2017 00:01:43 +0000 (18:01 -0600)]
ExtUtils::ParseXS/lib/perlxs.pod: Nits

This removes extra blanks following colons that don't mean the normal
thing for colons that traditionally have two spaces after them, and
capitalizes Perl.

6 years agomakedef.pl: Use all #ifdefs to decide
Karl Williamson [Fri, 16 Feb 2018 22:15:06 +0000 (15:15 -0700)]
makedef.pl: Use all #ifdefs to decide

This uses all the conditions that go in to deciding to define this
variable, instead of taking a shortcut.  (It's unfortunate that the
shortcut defined in perl.h now used elsewhere via commit
7e5377f714ebe84e0fe2599b3bfec50036f0d18f is not available to makedef.pl.
It would make sense to have this file look at perl.h and avoid
duplication).

This fixes some freebsd builds, which failed because their hints file
undef'd a different variable than this shortuct looked at.

6 years agoUse proper #define to see if need PLnumeric underlying_obj
Karl Williamson [Tue, 13 Feb 2018 23:34:27 +0000 (16:34 -0700)]
Use proper #define to see if need PLnumeric underlying_obj

perl.h has a single #define which is the combination of several that
determines if this object should be created or not.

6 years agoperl.h Move some #defines
Karl Williamson [Tue, 13 Feb 2018 23:25:14 +0000 (16:25 -0700)]
perl.h Move some #defines

These are used so that they appear ahead of #include intrpvar.h, so
they can be used by that file.  This enables this commit to simplify
some #ifdefs

6 years agoRevise when POSIX 2008 ops on FreeBSD
Karl Williamson [Thu, 15 Feb 2018 04:18:52 +0000 (21:18 -0700)]
Revise when POSIX 2008 ops on FreeBSD

It appears that bugs in FreeBSD are not fully fixed until later than we
thought, and so this commit updates the hints file to exclude POSIX 2008
operations on releases previously permitted.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211743

6 years agoPOSIX.xs: Fix localeconv_l()
Karl Williamson [Thu, 15 Feb 2018 11:22:19 +0000 (04:22 -0700)]
POSIX.xs: Fix localeconv_l()

Commit 7d5966ae3c3b8f0e43fa09554a46cb8de9c98f5f added use of
localeconv_l().  But this commit is buggy in some locales.  It needs to
find the current locale AFTER any changes have been made due to the
LC_NUMERIC locale toggling.

6 years agoregcomp.c: Add cast to avoid compiler warning
Karl Williamson [Sun, 18 Feb 2018 15:46:56 +0000 (08:46 -0700)]
regcomp.c: Add cast to avoid compiler warning

6 years agoUpdate dist/if/Changes to current version in blead.
James E Keenan [Sun, 18 Feb 2018 00:19:58 +0000 (19:19 -0500)]
Update dist/if/Changes to current version in blead.

6 years agoAdd MANIFEST to PathTools
Sawyer X [Sat, 17 Feb 2018 20:22:04 +0000 (22:22 +0200)]
Add MANIFEST to PathTools

6 years agoReflect what I think are the correct changesets for PathTools:
Sawyer X [Sat, 17 Feb 2018 20:18:38 +0000 (22:18 +0200)]
Reflect what I think are the correct changesets for PathTools:

Building towards an upcoming release of PathTools, I'm documenting
based on the commits what I think is the correct Changeset.

Considering that at the time of this commit, CPAN only has
PathTools 3.62, I think we should be fine.

Correct if you see a mistake. :)

6 years agodefine NEED_croak_xs_usage in PathTools
Zefram [Sat, 17 Feb 2018 18:10:48 +0000 (18:10 +0000)]
define NEED_croak_xs_usage in PathTools

ppport.h nowadays defines croak_xs_usage(), which is of course used
in the XS code, but its definition is broken unless the flag macro
NEED_croak_xs_usage was defined first.  Define the flag macro to avoid
breakage.

6 years agoAdd ABSTRACT, LICENSE, AUTHOR, etc. elements.
James E Keenan [Sun, 11 Feb 2018 16:49:19 +0000 (11:49 -0500)]
Add ABSTRACT, LICENSE, AUTHOR, etc. elements.

Add them conditionally so that CPAN PathTools can accommodate different
versions of ExtUtils::MakeMaker and CPAN metadata protocols.

Styled after Module-CoreList's Makefile.PL for better readability.

See: RT 132853

6 years agoEnsure that all tests in t/cwd.t have descriptions.
James E Keenan [Sun, 11 Feb 2018 16:44:21 +0000 (11:44 -0500)]
Ensure that all tests in t/cwd.t have descriptions.

6 years agoProvide .gitignore for PathTools distribution.
James E Keenan [Sun, 11 Feb 2018 16:36:45 +0000 (11:36 -0500)]
Provide .gitignore for PathTools distribution.

6 years agoUpdate ExtUtils-MakeMaker to CPAN version 7.32
Chris 'BinGOs' Williams [Sat, 17 Feb 2018 10:42:32 +0000 (10:42 +0000)]
Update ExtUtils-MakeMaker to CPAN version 7.32

  [DELTA]

7.32  Fri Feb 16 20:10:58 GMT 2018

    No changes since v7.31_08

7.31_08 Mon Feb 12 12:19:11 GMT 2018

    VMS fixes:
    - Fix 8-space line prefixes in MM_VMS.pm

7.31_07 Tue Jan 16 16:09:04 GMT 2018

    Bug fixes:
    - Change warning text for libscan() README.pod

7.31_06 Tue Jan 16 10:28:11 GMT 2018

    Bug fixes:
    - Teach libscan() to exclude README.pod

    Doc fixes:
    - Documented when XSMULTI and XSBUILD are available
    - Documented more version requirements for attributes

7.31_05 Sat Nov 25 09:22:51 GMT 2017 (LPW Edition)

    Doc fixes:
    - Spelling fixes
    - clarify behaviour if VENDORLIB and no VENDORARCH

7.31_04 Thu Oct  5 12:22:24 BST 2017

    Darwin/NeXT fixes:
    - Escape ld -framework flags

7.31_03 Mon Jul 10 09:34:26 BST 2017

    Bug fixes:
    - Filter out non-XS .a files for static builds

7.31_02 Mon Jun 26 13:53:15 BST 2017

    VMS fixes:
    - Fixes for .PL tests
    - VMS override for static_lib_pure_cmd
    - Make the new subdirsstatic test portable

7.31_01 Wed Jun 14 15:57:52 BST 2017

    Test fixes:
    - Skip static test unless in perl core or in a .git directory

6 years agoChange name of regnode for clarity
Karl Williamson [Sat, 17 Feb 2018 04:33:24 +0000 (21:33 -0700)]
Change name of regnode for clarity

The EXACTFA nodes are in fact not generated by /a, but by /aa.  Change
the name to EXACTFAA to correspond.

I found myself getting confused by this.

6 years agoAPItest: Add U8* typemap, and use it
Karl Williamson [Mon, 12 Feb 2018 16:03:09 +0000 (09:03 -0700)]
APItest: Add U8* typemap, and use it

This missiing typemap has slowed me down on numerous occasions, as I
keep forgetting it's missing

6 years agoNo list open on VMS as yet.
Craig A. Berry [Fri, 16 Feb 2018 20:12:11 +0000 (14:12 -0600)]
No list open on VMS as yet.

So do things the old way in openpid.t on VMS only.

6 years agodon't clobber file bytes in :encoding layer
Zefram [Fri, 16 Feb 2018 17:20:34 +0000 (17:20 +0000)]
don't clobber file bytes in :encoding layer

The PerlIO::encoding layer, when used on input, was creating an SvLEN==0
scalar pointing into the byte buffer, to pass to the ->decode method
of the encoding object.  Since the method mutates this scalar, for some
encodings this led to mutating the byte buffer, and depending on where
it came from that might be something visible elsewhere that should not
be mutated.  Remove the code for the SvLEN==0 scalar, instead always
using the alternate code that would copy the bytes into a separate buffer
owned by the scalar.  Fixes [perl #132833].

6 years agoFix gcc/dmake build on Windows
Steve Hay [Fri, 16 Feb 2018 08:59:04 +0000 (08:59 +0000)]
Fix gcc/dmake build on Windows

Remove circular dependency in makefile.mk, following the same pattern as in
GNUmakefile.

6 years agoutf8.c: Silence compiler warnings
Karl Williamson [Thu, 15 Feb 2018 18:07:16 +0000 (11:07 -0700)]
utf8.c: Silence compiler warnings

These are spurious warnings, from netbsd

6 years agoavoid vivifying UNIVERSAL::isa:: in Carp
Zefram [Thu, 15 Feb 2018 18:21:14 +0000 (18:21 +0000)]
avoid vivifying UNIVERSAL::isa:: in Carp

The test added to Carp by commit 915a6810d3e3198d759f025f85d1fd6f3171dd27
for UNIVERSAL::isa being loaded had the side effect of vivifying the
UNIVERSAL::isa stash.  Take more care about checking for UNIVERSAL::isa
to avoid vivifying it, as for the other checks for things in optional
modules.  Fixes [perl #132788].

6 years agoExtUtils::ParseXS::Eval: Fix variable name ALIAS in documentation
Pali [Fri, 9 Feb 2018 11:02:34 +0000 (12:02 +0100)]
ExtUtils::ParseXS::Eval: Fix variable name ALIAS in documentation

Correct name of variable is ALIAS, not Alias.

Committer: Increment all $VERSION to 3.38 for consistency (per demerphq).

6 years agoCorrect typo: agreement in tense.
James E Keenan [Thu, 15 Feb 2018 14:16:14 +0000 (09:16 -0500)]
Correct typo: agreement in tense.

6 years agoperldelta for b6811f8d3a5c
Tony Cook [Thu, 15 Feb 2018 03:52:33 +0000 (14:52 +1100)]
perldelta for b6811f8d3a5c

6 years ago[perl #121028] avoid creating a shell process
Tony Cook [Tue, 28 Jan 2014 04:52:22 +0000 (15:52 +1100)]
[perl #121028] avoid creating a shell process

Win32 now has list form open, so this can now be supplied.

6 years agoUpdate IPC-Cmd to CPAN version 1.00
Chris 'BinGOs' Williams [Wed, 14 Feb 2018 16:51:31 +0000 (16:51 +0000)]
Update IPC-Cmd to CPAN version 1.00

  [DELTA]

1.00 Wed Feb 14 16:14:01 GMT 2018

  Bug fixes:
  - Resolve RT #91784  'run_forked("/usr/bin/echo test") captures no output'
  - Resolve RT #124415 'The 03_run_forked.t test fails (sometimes) on HPUX'

6 years agoUpdate link in documentation.
James E Keenan [Wed, 14 Feb 2018 13:47:12 +0000 (08:47 -0500)]
Update link in documentation.

Original link was reported dead and replacement link suggested by freethunk.

For: RT # 123859

6 years agoConstruct Limit.pm dependency with File::Spec.
Craig A. Berry [Sun, 11 Feb 2018 22:33:29 +0000 (16:33 -0600)]
Construct Limit.pm dependency with File::Spec.

Paths passed to WriteMakefile() will get converted to whatever
format is necessary for the make or make-like utility being used,
but paths in hard-coded extra dependencies will not.  So construct
the target name with File::Spec->catfile().

6 years agoVMS does have wchar.h.
Craig A. Berry [Sun, 11 Feb 2018 22:29:32 +0000 (16:29 -0600)]
VMS does have wchar.h.

And we now need it for prototypes of functions that locale.c is
using.

6 years agoregcomp.c: Under/i segregate folding vs non-folding characters
Karl Williamson [Mon, 5 Feb 2018 02:43:00 +0000 (19:43 -0700)]
regcomp.c: Under/i segregate folding vs non-folding characters

For matching sequences of characters, the regex compiler generates
various flavors of EXACT-type nodes.  The optimizer uses those nodes to
look for sequences that must be in the matched string.  In this way, the
pattern matching engine may be able to quickly rule out any possible
match altogether, or to narrow down the places in the target string that
might match.

Under /i matching, this generally has not been possible, because there
is no fixed string that the optimizer can grab onto, as something can
match, say, either 'A' or 'a', etc.  However, in many patterns that
contain text, there are characters that are fixed even under /i.  Things
like tabs, space, and punctuation, for example.

This commit segregates such folding vs non-folding characters into
separate nodes.  I proposed this 7 months ago:

http://nntp.perl.org/group/perl.perl5.porters/245342

and in talking with Yves recently, decided to go ahead with it.

In the proposal of July, I suggested that a new node type be used to
mark those nodes which are under /i but contain no characters that match
other than themselves under /i.  These nodes could be joined with either
a plain EXACT node, or an EXACTFish one to create longer nodes.

The reason for joining is that there is overhead in the engine whenever
we switch to the next node.  But the reason for not doing it is that it
is slower to match /i nodes than ones that an memEQ can be used on.

I suppose we could join short nodes, and leave longer ones separate, but
that decision can be deferred based on real-world experience.

This patch also consolidates into one place the handling of the Latin
Sharp S, in order to avoid extra #ifdefs, and cause the logic to be
linearly shown.

6 years agoUpgrade Encode from version 2.94 to 2.96
Steve Hay [Mon, 12 Feb 2018 20:37:36 +0000 (20:37 +0000)]
Upgrade Encode from version 2.94 to 2.96

6 years ago(perl #127743) remove the no longer needed stacksize_in.h
Tony Cook [Mon, 12 Feb 2018 00:02:26 +0000 (11:02 +1100)]
(perl #127743) remove the no longer needed stacksize_in.h

I should have removed this when I changed the limits from being baked
into the binary.

6 years ago(perl #132849) try to disable core files when deliberatly segfaulting
Tony Cook [Sun, 11 Feb 2018 23:50:24 +0000 (10:50 +1100)]
(perl #132849) try to disable core files when deliberatly segfaulting

The dist/Storable/stacksize tool probes for recursion limits for
Storable, in an attempt to prevent stack overflows, and causes
segfaults when the probes exceed the available stack size.

This was leaving a core file for each failure (whether that ended
up as a single file or one for each segfault depended on the
system settings).

Try to probe for the ulimit -c option and if it doesn't cause an
error, prefix the command used to probe for recursion limits.

Ideally I could use setrlimit() for this, but we don't expose it in
core, nor in POSIX.pm, and adding it wouldn't help for the older
perls that Storable needs to build for.

6 years agopodcheck.t: Recognize more forms of core files
Karl Williamson [Mon, 12 Feb 2018 00:39:29 +0000 (17:39 -0700)]
podcheck.t: Recognize more forms of core files

This extends 199fc8cde4ec30a56626c0765b3b0efacb327664 to include more
common forms of core files.

.*\.core.*
core
core\..*

should all now be ignored.

6 years agobump $warnings::VERSION
Tony Cook [Mon, 12 Feb 2018 00:07:14 +0000 (11:07 +1100)]
bump $warnings::VERSION

since warnings.(pm|pl) was updated in 25ebbc2270

6 years agoTest for _at_level functions with fh
Father Chrysostomos [Sun, 11 Feb 2018 20:40:09 +0000 (12:40 -0800)]
Test for _at_level functions with fh

6 years agowarnings: Omit handle when $. is 0
Slaven Rezić [Sun, 11 Feb 2018 20:36:07 +0000 (12:36 -0800)]
warnings: Omit handle when $. is 0

otherwise the new _at_level functions end up including
‘at <handle> line 0’.

[Commit message by the committer.]

6 years agoDon't export PL_underlying_numeric_obj if it doesn't exist.
Craig A. Berry [Sat, 10 Feb 2018 23:05:07 +0000 (17:05 -0600)]
Don't export PL_underlying_numeric_obj if it doesn't exist.

This broke the build on VMS and probably would on anything else
with strict linking where HAS_NEW_LOCALE is not defined.

6 years agopodcheck.t: Skip core files in all directories
Karl Williamson [Sat, 10 Feb 2018 22:17:29 +0000 (15:17 -0700)]
podcheck.t: Skip core files in all directories

Commit 446f12a860e9ab9b234cd6796e937fbff85adf5c only skipped files named
'core' in the top directory.  This should skip them in any directory.

6 years agopodcheck.t: Skip core files
Karl Williamson [Sat, 10 Feb 2018 20:50:54 +0000 (13:50 -0700)]
podcheck.t: Skip core files

This is the likely cause of
https://rt.perl.org/Ticket/Display.html?id=132843

6 years agoAPItest: Fix C++ compiles
Karl Williamson [Fri, 9 Feb 2018 17:10:47 +0000 (10:10 -0700)]
APItest: Fix C++ compiles

0a9f8f95112ff40e13406b3e5aab49c01487f045 introduced failures on C++
compilations.  This is a better patch, suggested by ilmari.

The issue was in cases where the pointer size is 32 bits and the word
size was 64, a (STRLEN) -1 returned as an error was getting turned into
0xFFFFFFFF instead of -1.

6 years agoAPItest: Correct parameter sign
Karl Williamson [Thu, 8 Feb 2018 20:51:48 +0000 (13:51 -0700)]
APItest: Correct parameter sign

Commit ae315a0a3c51e68887704d4907bb6a502a6d4e3f added tests for
utf8_to_bytes().  For testing purposes, this parameter should be signed
when it comes from perl space.

6 years agoUpgrade Time::HiRes from version 1.9752 to 1.9753
Steve Hay [Thu, 8 Feb 2018 13:40:09 +0000 (13:40 +0000)]
Upgrade Time::HiRes from version 1.9752 to 1.9753

6 years agoUpgrade Test-Simple from version 1.302120 to 1.302122
Steve Hay [Thu, 8 Feb 2018 13:37:16 +0000 (13:37 +0000)]
Upgrade Test-Simple from version 1.302120 to 1.302122

6 years agoUpgrade bignum from version 0.47 to 0.49
Steve Hay [Thu, 8 Feb 2018 13:30:27 +0000 (13:30 +0000)]
Upgrade bignum from version 0.47 to 0.49

6 years agoutil.c: Fix typo in comment
Karl Williamson [Thu, 8 Feb 2018 05:40:23 +0000 (22:40 -0700)]
util.c: Fix typo in comment

6 years ago(perl #127743) merge Storable work to date
Tony Cook [Thu, 8 Feb 2018 03:23:43 +0000 (14:23 +1100)]
(perl #127743) merge Storable work to date

This merges a large number of changes from cperl Storable, largely for
64-bit object support, and then further extends 64-bit object support
and fixes a number of other issues.

6 years agobump $Storable::VERSION to 3.06
Tony Cook [Tue, 16 Jan 2018 04:50:24 +0000 (15:50 +1100)]
bump $Storable::VERSION to 3.06

6 years ago(perl #127743) update Changes
Tony Cook [Wed, 7 Feb 2018 04:56:24 +0000 (15:56 +1100)]
(perl #127743) update Changes

6 years ago(perl #127743) re-work recursion limit handling
Tony Cook [Wed, 10 Jan 2018 00:32:43 +0000 (11:32 +1100)]
(perl #127743) re-work recursion limit handling

Previously this worked by calculating the limits and then rebuilding
Storable.so, this meant Storable.so was built twice meaning a new make
would then rebuild its dependencies.

This was also a hard limit, so if Storable's user knew the available
stack space changed they would need to rebuild Storable to adapt.

This also allows for successful static Storable builds.

I also updated the stacksize tool to prevent popping up segfault error
messages at the user on Win32.

Since I was still seeing test failures in recurse.t on a variety of
platforms, I made the default limit calculations even more
conservative.

6 years ago(perl #50608) add experimental regular expression support
Tony Cook [Tue, 19 Dec 2017 00:06:31 +0000 (01:06 +0100)]
(perl #50608) add experimental regular expression support

This doesn't work on 5.6, but I'm not sure why.

For a bad regular expression _make_re() throws an exception, and it's
propagated back to the original caller, and execution continues.

But after the program is complete retrieve_regexp() continues
execution from the call_pv(), typically with count == -1 and dies
horribly.

6 years ago(perl #127743) fix dependencies for Storable.pm
Tony Cook [Mon, 18 Dec 2017 05:06:10 +0000 (06:06 +0100)]
(perl #127743) fix dependencies for Storable.pm

Since ad2ec6b5 Storable.pm has been generated by Storable.pm.PL from
__Storable__pm.

Unfortunately the PL_FILES EU::MM key doesn't let you specify any
dependencies beyond the .PL file, so modifications to __Storable__.pm
weren't causing Storable.pm to rebuilt.

So I've replaced PL_FILES with an empty hash (to prevent EU::MM
generating once) and added my own rule.

6 years ago(perl #25933) always rethrow exceptions thrown through or by the XS implementation
Tony Cook [Mon, 11 Dec 2017 22:02:47 +0000 (23:02 +0100)]
(perl #25933) always rethrow exceptions thrown through or by the XS implementation

Also, preserve any references thrown.

Such references could be thrown by STORABLE_freeze, STORABLE_thaw or
STORABLE_attach implementations.

Several of the wrappers in Storable.pm had code similar to:

  eval { ... };
  logcroak $@ if $@ =~ s/\.?\n$/,/;

with $@ discarded if the condition failed.

This lead to two problems:

- exceptions not ending in "\n" (which is just references without
  string overloading, or with overloading but that didn't return a
  string ending in "\n") would not be rethrown.

- thrown references that did happen to have overloading that returned
  "\n" would be converted into strings.

This behaviour appears to have been present since the initial release
of Storable.

6 years ago(perl #127743) improve performance in -DDEBUGGING builds
Tony Cook [Sun, 10 Dec 2017 23:53:35 +0000 (00:53 +0100)]
(perl #127743) improve performance in -DDEBUGGING builds

The changes imported from cperl included a change to enable Storable's debugging
output mechanism for -DDEBUGGING builds.

When built with debugging output, Storable's TRACEME() macro fetched
the $Storable::DEBUGME global and checked its truth, this
significantly slowed down Storable, especially noticable for dumps
with large numbers of objects.

I added a cached traceme value to the Storable context object and
modified TRACEME() to used that instead.  A few TRACEME()'s that are
called before the context object is available have been replaced with
calls to TRACEMD(), a new macro that does what TRACEME() did before.

6 years ago(perl #131136) clear padding before writing long doubles
Tony Cook [Thu, 7 Dec 2017 00:47:47 +0000 (01:47 +0100)]
(perl #131136) clear padding before writing long doubles

This means:

- valgrind won't complain about uninitialized bytes when writing long doubles

- we get consistent output when writing equivalent data structures

6 years ago(perl #118551) an empty string from _freeze() now supplies the same to _thaw()/_attach()
Tony Cook [Wed, 6 Dec 2017 00:52:20 +0000 (01:52 +0100)]
(perl #118551) an empty string from _freeze() now supplies the same to _thaw()/_attach()

The retrieve_hook() code would simply pass the string length to
NEWSV(), so if the length was zero, no PV would be allocated, and the
SV would not be upgraded.

The following code would then set POK on an SV that wasn't SVt_PV (or
better), resulting in fun later down the line.

Change to always supply at least 1 as the buffer size for NEWSV(), and
always set CUR and NUL terminate the buffer.

6 years ago(perl #127743) ensure gzip/gzip are available before we use them
Tony Cook [Tue, 5 Dec 2017 05:53:16 +0000 (06:53 +0100)]
(perl #127743) ensure gzip/gzip are available before we use them

6 years ago(perl #127743) support for >= 4GB data from hooks
Tony Cook [Tue, 5 Dec 2017 04:24:20 +0000 (05:24 +0100)]
(perl #127743) support for >= 4GB data from hooks

Though we use this mechanism for >= 2GB.

This emits an SX_LOBJECT op and writes the string length as a 64-bit
value if STORABLE_attach() returns more than 2GB of data.

The boundary is set at 2GB since older versions of Storable handle
sizes between 2GB and 4GB badly, resulting in a memory overwrite.  By
using the alternate op codes an older Storable will reject the data
instead.

We still accept such data that might have been written by an older
Storable.

6 years ago(perl #131999) treat a 32-bit hook data size as unsigned
Tony Cook [Mon, 4 Dec 2017 23:42:48 +0000 (00:42 +0100)]
(perl #131999) treat a 32-bit hook data size as unsigned

Previously retrieve_hook() treated the 32-bit hook data size as a signed value, but
the parameter to NEWSV() is treated as unsigned.  Due to promotion rules this negative
signed value is converted to a very large unsigned value running us out of memory.

Fixing this bug will let us accept previously frozen hook data in the
2GB to 4GB rannge.  The next commit will hopefully allow us to write
and read 4GB+ data correctly.

6 years ago(perl #131990) treat the length for LSCALAR, LUTF8STR as unsigned
Tony Cook [Mon, 4 Dec 2017 04:49:27 +0000 (15:49 +1100)]
(perl #131990) treat the length for LSCALAR, LUTF8STR as unsigned

Older Storable without 64-bit object might write such objects.

A malicious file might also be provided with such a large length
to cause a resource consumption attack (allocating large amounts of
memory), but Storable explicitly doesn't protect against attacks.

6 years agowe only need 64-bit object support with 64-bit pointer builds
Tony Cook [Mon, 4 Dec 2017 03:41:45 +0000 (14:41 +1100)]
we only need 64-bit object support with 64-bit pointer builds

Previously this enabled 64-bit object support with 64-bit int builds,
such as a 32-bit build with -Duse64bitint supplied to Configure,
but a 32-bit system can't realistically have more than 2**31 array
elements or hash elements.

With an operating system built or configured especially to allow it
you might be able to find a 32-bit system that supported a PV with more
than 2**31 bytes, but that seems unlikely and not a case to optimize for.

6 years agofix various 32-bit issues:
Tony Cook [Mon, 4 Dec 2017 03:41:19 +0000 (14:41 +1100)]
fix various 32-bit issues:

- the comparison against where_is_undef caused signed vs unsigned
  comparison warnings

- don't define get_larray() on 32-bit builds

6 years ago(perl #127743) read the hash's flags for large SX_FLAG_HASH ops
Tony Cook [Wed, 22 Nov 2017 04:24:29 +0000 (05:24 +0100)]
(perl #127743) read the hash's flags for large SX_FLAG_HASH ops

Unfortunately testing this requires more memory than any machine I
have available has.

6 years ago(perl #127743) we should only handle SX_LOBJECT ops on 64-bit platforms
Tony Cook [Tue, 21 Nov 2017 23:17:33 +0000 (00:17 +0100)]
(perl #127743) we should only handle SX_LOBJECT ops on 64-bit platforms

retrieve_lobject() handled such large objects I'm assuming to handle
smaller sizes stored in a 64-bit length/count, but that can only
happen if someone isn't using Storable to generate the data.

6 years ago(perl #127743) fix network order read/write of large values
Tony Cook [Tue, 21 Nov 2017 04:55:32 +0000 (05:55 +0100)]
(perl #127743) fix network order read/write of large values

This had a couple of bugs:

- W64LEN() used a union where it should have used an array or struct,
  so a network order 64-bit length was written as 4 bytes.  Oops.

  Changed to use an array.

- retrieve_lobject() always read the length in host order, so it sort
  of tried to read the length in network order on 32-bit platforms,
  but then didn't fix the order of the length it read.

  Now uses READ_U64() (which I originally messed up myself, oops.)

6 years ago(perl #127743) fixes for READ_U64()
Tony Cook [Tue, 21 Nov 2017 04:51:07 +0000 (05:51 +0100)]
(perl #127743) fixes for READ_U64()

- ntohl() the low word too, doh

- if ntohl() isn't provided, then provide it, with appropriate
  wrapping.  Should be exteneded to other uses.

- only available for 64-bit builds

6 years ago(perl #127743) fix some -DDEBUGGING build issues
Tony Cook [Tue, 21 Nov 2017 04:12:16 +0000 (05:12 +0100)]
(perl #127743) fix some -DDEBUGGING build issues

6 years ago(perl #127743) limit the number of extra refs returned by STORABLE_freeze
Tony Cook [Mon, 20 Nov 2017 23:05:28 +0000 (00:05 +0100)]
(perl #127743) limit the number of extra refs returned by STORABLE_freeze

Ensure some over enthusiastic STORABLE_freeze() doesn't cause us to
emit a negative reference count for SX_HOOK.

This fails to be parsed by older versions and flags 64-bit ids for new
versions of Storable.

6 years ago(perl #127743) fix large object ids in hook sequences
Tony Cook [Thu, 2 Nov 2017 05:55:45 +0000 (06:55 +0100)]
(perl #127743) fix large object ids in hook sequences

As with SX_OBJECT, if there are a large number of SVs being frozen the
object ids can exceed the 32-bit limit.

The problem here is how to indicate that we have 64-bit ids without
breaking older versions parsing our results for smaller object trees?

We don't have any room in the flags byte, currently used as:

 bits  use
 ----  ---
 0,1   type
 2     class length is > 255 bytes
 3     frozen string > 255 bytes
 4     more than 255 extra references
 5     class name has been seen before and is represented as an index
 6     an extra reference is stored next
 7     has a list of extra references

and the extra byte is only used for tied SVs.  We can't repurpose the
bits 6, 7 since it would break older readers.

I considered adding SX_LARGE_HOOK, or something similar, but we find
out that large ids are needed well after the op code has been emitted.

So how is the handling of the length + ids handled in retrieve_hook()?

    I32 len3 = 0;
    ...
        if (flags & SHF_LARGE_LISTLEN)
            RLEN(len3);
else
            GETMARK(len3);
        if (len3) {
            av = newAV();
            av_extend(av, len3 + 1); /* Leave room for [0] */
            AvFILLp(av) = len3; /* About to be filled anyway */
        }

For SHF_LARGE_LISTLEN this treats the len3 as signed - so if the
writer had more than 2**31-2 objects after the "frozen" string,
decoding is going to break anyway, as av_extend_guts() panics on "key"
values less than -1.

The code that actually reads the ids will fail to read any ids when
len3 is negative, since the for loop does a i <= len3 check.

So rather than trying to fix this, I used a negative len3 to indicate
that the object ids are 64-bit.

This means we get backward compatibility in the cases where 32-bit ids
work, and older versions of Storable will reject it.

If an older version of Storable wrote a negative len3 (due to
overflow) we'll be attempting to read 32-bit ids as typically very
large 64-bit ids (much larger than 2**32 in most cases) which won't be
found in the seen array, failing the thaw.

6 years ago(perl #127743) update PERL_TEST_MEMORY requirements for the older tests
Tony Cook [Wed, 1 Nov 2017 22:58:49 +0000 (23:58 +0100)]
(perl #127743) update PERL_TEST_MEMORY requirements for the older tests

PERL_TEST_MEMORY includes any swap, it's not the minimum resident set
for the test.

6 years ago(perl #127743) fix two problems with large object ids
Tony Cook [Wed, 1 Nov 2017 22:31:39 +0000 (23:31 +0100)]
(perl #127743) fix two problems with large object ids

Storable assigns an object id to every scalar it freezes, including to
unused elements in arrays.

There were two problems here:

a) in retrieve(), object ids over 2**31-1 but less than 2**32 were
   treated as signed, so the wrong object was produced in the resulting
   data structure.  Two changes we made to fix this:

  i)  retrieve() now treats object ids in the problem range as
      unsigned, so data written by older Storables is now treated
      correctly.

  ii) store() now writes object ids in the problem range as 64-bit
      ids, so that older Storables will fail rather than producing an
      incorrect result data structure.

b) once over 2**32 scalars had been output, the code still produced
   32-bit object ids when referring to previous scalars.  Fixed by
   adding support for 64-bit object ids.

There's still an issue with object ids in hook produced data.

Testing these changes requires ridiculous amounts of memory - ~32GB
for a) and ~66GB for b), and the tests take a long time to run, hence
for those tests to run you need the following in the environment;

  PERL_TEST_MEMORY >= 70
  PERL_RUN_SLOW_TESTS != 0

6 years ago(perl #127743) correct some types for Win32
Tony Cook [Wed, 25 Oct 2017 02:55:52 +0000 (13:55 +1100)]
(perl #127743) correct some types for Win32

In a couple of places the code uses unsigned long to represent values
possibly larger than 2**32, but long is 32-bits on x64 Win32, so
use STRLEN or Ssize_t instead.

6 years agoStorable 3.05_13: safe defaults
Reini Urban [Mon, 24 Jul 2017 11:58:37 +0000 (13:58 +0200)]
Storable 3.05_13: safe defaults

mingw fix: use safe defaults, not segfaulting defaults.
mingw fails on the stacksize binary search, leaving it empty.

(cherry picked from commit 27c613e5f8dfab7b8b43a57e93a478aa962dd9ca)

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

6 years agoStorable: Analyze #304
Reini Urban [Fri, 14 Jul 2017 14:15:40 +0000 (16:15 +0200)]
Storable: Analyze #304

Add a better error message on one of the possible failure causes
when the system cannot catch the stackoverflow.

(cherry picked from commit 3f655dc6444cd56d09d4a99a4be5a92c1119506b)

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)