This is a live mirror of the Perl 5 development currently hosted at
17 months agoperldata - More specific about assignment restriction of key/value slices
Dan Book [Sat, 11 Apr 2020 05:55:05 +0000 (01:55 -0400)]
perldata - More specific about assignment restriction of key/value slices

17 months agoTime-Piece: synch with CPAN version 1.3401
Samuel Smith [Thu, 9 Apr 2020 18:58:56 +0000 (14:58 -0400)]
Time-Piece: synch with CPAN version 1.3401

From Changes:

1.3401  2020-04-06
        - Add tests for negative and large epochs
        - Remove %I tests from 09locales.t
        - Exempt more tests unless $ENV{AUTOMATED_TESTING}
        - Safeguards around 12-hour time notation

1.34    2020-02-27
        - Exempt DST tests unless $ENV{AUTOMATED_TESTING}
        - Add recent test files to MANIFEST (openstrike)

Committer:  Time-Piece maintainer is now a Perl author

17 months agoperlbug - Change default behavior to save to file
Dan Book [Sat, 14 Mar 2020 22:58:18 +0000 (18:58 -0400)]
perlbug - Change default behavior to save to file

Output filename now always defaults to "perlbug.rep".
Sends by email only if an address is specified with -a,
invoked as perlthanks or with -T, or the prompt is
chosen to send the report to perl5-porters.
Removed option -A as it no longer does anything.
Clarified output to refer to "report" instead of "message".

17 months agoBump back to 5.31.11, if we need to release it
Sawyer X [Sat, 21 Mar 2020 20:04:26 +0000 (22:04 +0200)]
Bump back to 5.31.11, if we need to release it

17 months agoAdd Atsushi Sugawara to AUTHORS
Karl Williamson [Mon, 6 Apr 2020 19:28:14 +0000 (13:28 -0600)]
Add Atsushi Sugawara to AUTHORS

17 months agoFix typo in perlretut.pod. C<'$'> to C<$'>.
Atsushi SUGAWARA [Mon, 6 Apr 2020 15:24:54 +0000 (00:24 +0900)]
Fix typo in perlretut.pod. C<'$'> to C<$'>.

17 months agodon't disable __attribute__((always_inline)) on clang
Tomasz Konojacki [Mon, 6 Apr 2020 11:04:05 +0000 (13:04 +0200)]
don't disable __attribute__((always_inline)) on clang

clang pretends to be gcc 4.2

17 months agodisable __attribute__((always_inline)) for gcc <= 4.6
Tomasz Konojacki [Mon, 6 Apr 2020 02:05:22 +0000 (04:05 +0200)]
disable __attribute__((always_inline)) for gcc <= 4.6

It was causing compilation errors in DEBUGGING builds:

pp_sort.c: In function 'sortsv_cmp_locale_desc':
pp_sort.c:1329:1: sorry, unimplemented: inlining failed in call to 'S_cmp_locale_desc': function not inlinable
pp_sort.c:188:17: sorry, unimplemented: called from here
pp_sort.c:1329:1: sorry, unimplemented: inlining failed in call to 'S_cmp_locale_desc': function not inlinable
pp_sort.c:194:21: sorry, unimplemented: called from here

17 months agoregcomp.c: Die on relative group number overflow
Karl Williamson [Sun, 5 Apr 2020 03:24:55 +0000 (21:24 -0600)]
regcomp.c: Die on relative group number overflow

That this code was doing in the presence of an illegally large (or
small) relative capturing group number was to set it to about the
furthest away from zero it could get, and silently carry on, where it
likely overflowed a few lines down.

Instead die immediately with a proper message.

17 months agoregcomp.c: Avoid a segfault
Karl Williamson [Sun, 5 Apr 2020 03:17:24 +0000 (21:17 -0600)]
regcomp.c: Avoid a segfault

This was resulting in C undefined behavior reported by asan.  Check that
won't overflow before doing the operation; then die instead of going
ahead anyway.

This fixes #17593

17 months agoregcomp.c: Rmv unnecessary code
Karl Williamson [Sun, 5 Apr 2020 03:10:58 +0000 (21:10 -0600)]
regcomp.c: Rmv unnecessary code

As spotted by Hugo van der Sanden, a barckwards reference to a capturing
group doesn't need to look forward instead.  If we don't have a
capturing group we already should have, looking forward won't magically
produce it.

17 months agoregcomp.c: Rmv wrong comment
Karl Williamson [Sun, 5 Apr 2020 03:06:52 +0000 (21:06 -0600)]
regcomp.c: Rmv wrong comment

This comment speculated that perhaps we should be testing for underflow.
But this isn't a problem on any extant computer hardware

17 months agoregcomp.c: Don't duplicate text for an error msg
Karl Williamson [Sun, 5 Apr 2020 02:58:30 +0000 (20:58 -0600)]
regcomp.c: Don't duplicate text for an error msg

Instead, have a common definition.

17 months agoregcomp.c: Look before leaping; check before alloc
Karl Williamson [Thu, 2 Apr 2020 03:10:25 +0000 (21:10 -0600)]
regcomp.c: Look before leaping; check before alloc

This moves the allocation of a new regnode to just after the check that
the contents are ok, instead of just before.

17 months agoperlapi: Clarify grok_atoUV()
Karl Williamson [Sun, 5 Apr 2020 02:54:05 +0000 (20:54 -0600)]
perlapi: Clarify grok_atoUV()

17 months agoConfigure can't find dlopen() on DragonFly BSD when using g++
Tomasz Konojacki [Sat, 4 Apr 2020 21:25:50 +0000 (23:25 +0200)]
Configure can't find dlopen() on DragonFly BSD when using g++

linux, freebsd and solaris hints have the same workaround

17 months agore/pat_advanced.t: Rmv extraneous line
Karl Williamson [Sat, 4 Apr 2020 19:19:00 +0000 (13:19 -0600)]
re/pat_advanced.t: Rmv extraneous line

Spotted by Dagfinn Ilmari Mannsåker

17 months agoregcomp.c: Handle /ss\xdf/iaa properly
Karl Williamson [Thu, 2 Apr 2020 04:29:19 +0000 (22:29 -0600)]
regcomp.c: Handle /ss\xdf/iaa properly

Having both ss and \xdf in a string caused the node type to be changed
back to a wrong one.

This fixes #17486

17 months agoDragonFly BSD doesn't support SO_PROTOCOL for AF_UNIX sockets
Tomasz Konojacki [Fri, 3 Apr 2020 19:45:13 +0000 (21:45 +0200)]
DragonFly BSD doesn't support SO_PROTOCOL for AF_UNIX sockets

17 months agoStorable: Fix t/huge.t PERL_TEST_MEMORY diagnostic messages
Dagfinn Ilmari Mannsåker [Thu, 2 Apr 2020 22:03:11 +0000 (23:03 +0100)]
Storable: Fix t/huge.t PERL_TEST_MEMORY diagnostic messages

Commit be827e1bf8824a339ec2b5f6f58542e456157bce fixed the checks to
match what was actually required, but failed to adjus the diagnostic
messages when the requirement was not satisfied.

17 months agoop.c: Add, clarify comments
Karl Williamson [Wed, 1 Apr 2020 14:06:17 +0000 (08:06 -0600)]
op.c: Add, clarify comments

17 months agotr/abc/de/: Properly handle longer lhs in in-place calc
Karl Williamson [Wed, 1 Apr 2020 12:05:06 +0000 (06:05 -0600)]
tr/abc/de/: Properly handle longer lhs in in-place calc

A tr/// can be done in-place if the target string doesn't contain a
character whose transliterated representation is longer than the
original.  Otherwise, writing the new value would destroy the next
character we need to read.

In general, we can't know if a particular string contains such a
character without keeping a list of the problematic characters, and
scanning it ahead of time for occurrences of those.  Instead, we
determine at compilation time if, for a given transliteration, if there
exists any possible target string that could have an overwriting
problem.  If none exist, we edit in place.  Otherwise, we first make a

Prior to this commit, the code failed to account for the case where the
rhs is shorter than the left, so that any unmatched lhs characters map
to the final rhs one.  The reason the code didn't consider this is that
I didn't think of this possibility when writing it.

This fixes #17654 and #17643

17 months agodoop.c: Fix typo in comment; add comment
Karl Williamson [Wed, 1 Apr 2020 11:46:43 +0000 (05:46 -0600)]
doop.c: Fix typo in comment; add comment

17 months agoext/XS-APItest/APItest.xs - make allowances for big endian architecture
sisyphus [Thu, 2 Apr 2020 06:26:27 +0000 (17:26 +1100)]
ext/XS-APItest/APItest.xs -  make allowances for big endian architecture

17 months agohv_macro.t - remove endianness considerations as they are unnecessary.
sisyphus [Thu, 2 Apr 2020 06:24:57 +0000 (17:24 +1100)]
hv_macro.t - remove endianness considerations as they are unnecessary.


17 months Bump version to 1.09
Karl Williamson [Tue, 31 Mar 2020 14:24:34 +0000 (08:24 -0600)] Bump version to 1.09

17 months - Clarify scoping of $^W examples
Dan Book [Wed, 1 Apr 2020 17:04:35 +0000 (13:04 -0400)] - Clarify scoping of $^W examples

17 months agoscan_commit: fix flag handling
Hugo van der Sanden [Mon, 30 Mar 2020 17:05:12 +0000 (18:05 +0100)]
scan_commit: fix flag handling

A regexp substring changing from SF_BEFORE_MEOL to SF_BEFORE_SEOL or vice
versa would wrongly end up with both flags.

17 months agoEliminate build-time warning
Zefram [Fri, 27 Mar 2020 22:54:10 +0000 (18:54 -0400)]
Eliminate build-time warning

Compiling with gcc7, for example, generated a '-Woverflow' warning with
text 'overflow in implicit constant conversion'.


17 months agoPerl_unipmlemented_op: Fix comment and unnecessary PL_op deref
Dagfinn Ilmari Mannsåker [Sun, 29 Mar 2020 20:40:01 +0000 (21:40 +0100)]
Perl_unipmlemented_op: Fix comment and unnecessary PL_op deref

The comment referred to pp_addr, but the correct field is op_ppaddr,
and the function itself is called Perl_unimplemented_op, not

When indexing PL_op_name[], use the local op_type variable that we
just got from PL_op->op_type instead of going via PL_op again.

17 months agoensure sv bodies are properly aligned
Tony Cook [Wed, 25 Mar 2020 04:08:43 +0000 (15:08 +1100)]
ensure sv bodies are properly aligned

In some cases SV bodies don't include the same members as lower sv type
bodies, in particular, PVMG includes an NV member, while PVCV and
other specialised bodies don't include it, so PVMG can have a larger
alignment boundary.

This can result in a PVCV having a smaller alignment boundary than
PVMG, resulting in potential undefined behaviour if a member that
is common between PVCV and PVMG is accessed on an lesser aligned
PVCV pointer.

To avoid that, ensure allocation sizes described in bodies_by_type[]
account for NV (and IV) alignment requirements.

fixes #17668

17 months agoregcomp.c: Add comment
Karl Williamson [Sun, 29 Mar 2020 16:22:09 +0000 (10:22 -0600)]
regcomp.c: Add comment

At the request of @hvds

17 months agoSync Test-Simple with CPAN version 1.302173
Chad Granum [Fri, 27 Mar 2020 18:31:03 +0000 (14:31 -0400)]
Sync Test-Simple with CPAN version 1.302173

17 months agodon't export PL_mbrlen_ps, PL_mbrtowc, PL_wcrtomb if not defined
Tony Cook [Thu, 26 Mar 2020 03:19:34 +0000 (14:19 +1100)]
don't export PL_mbrlen_ps, PL_mbrtowc, PL_wcrtomb if not defined

These variables are only defined when the appropriate symbols are
defined in config.h, which are controled by their respective names

Note that the earlier code in only defines the intrpvar.h
symbols for non-multiplicity builds, so there's no need to special
case this check for threaded/multiplicity builds where these symbols
are never defined.

A sufficiently modern MSVC CRT does turn out to define these symbols,
but fixing this error first.

17 months agogh-17645: avoid oob read on conflict marker detection
Hugo van der Sanden [Fri, 27 Mar 2020 14:35:24 +0000 (14:35 +0000)]
gh-17645: avoid oob read on conflict marker detection

Introduced in 0ae5281a2d.

17 months agogh-17645 test for out of bounds read
Hugo van der Sanden [Fri, 27 Mar 2020 14:31:38 +0000 (14:31 +0000)]
gh-17645 test for out of bounds read

TODO test fails with sanitize=address.

17 months agoapparently HP-UX and solaris also don't support SO_PROTOCOL for AF_UNIX
Tony Cook [Fri, 27 Mar 2020 03:47:14 +0000 (14:47 +1100)]
apparently HP-UX and solaris also don't support SO_PROTOCOL for AF_UNIX

17 months agoDebugging GH #17671.
Karl Williamson [Wed, 25 Mar 2020 00:49:07 +0000 (18:49 -0600)]
Debugging GH #17671.

We are seeing an occasional smoke failure in the experimental regular
expression Unicode property wildcard feature for the name property.
This is not reproducible, and neither valgrind nor asan shows anything.
All the failures I have seen involve looking up NULL.  Now it could be
something special about that name, or merely that it is the first in the
test to be checked.  This commit seeks to find out by skipping that
test.  If we stop getting these intermittent failures, it points one
direction; if they continue with 0x01, instead, it points in another.

18 months agotest for i Foo failing to load mro
Tony Cook [Mon, 23 Mar 2020 00:47:24 +0000 (11:47 +1100)]
test for i Foo failing to load mro

test for #17660

18 months agocheckAUTHORS: another name for rjbs
Ricardo Signes [Fri, 20 Mar 2020 02:19:32 +0000 (22:19 -0400)]
checkAUTHORS: another name for rjbs

18 months the "i" command must load before use
Ricardo Signes [Thu, 19 Mar 2020 18:10:05 +0000 (14:10 -0400)] the "i" command must load before use

18 months agoperlfunc - explicitly describe relationship between sysopen, sysread, syswrite, and...
Dan Book [Sun, 22 Mar 2020 21:02:59 +0000 (17:02 -0400)]
perlfunc - explicitly describe relationship between sysopen, sysread, syswrite, and PerlIO

18 months agoSetting version to RC0
Sawyer X [Sat, 21 Mar 2020 14:29:25 +0000 (16:29 +0200)]
Setting version to RC0

18 months agoBump Module::CoreList in Maintainers, update rest
Sawyer X [Sat, 21 Mar 2020 13:03:38 +0000 (15:03 +0200)]
Bump Module::CoreList in Maintainers, update rest

18 months agoUpdate epigraph link, tick release in another place
Sawyer X [Sat, 21 Mar 2020 12:55:17 +0000 (14:55 +0200)]
Update epigraph link, tick release in another place

18 months agoUpdate Module::CoreList for 5.32.0
Sawyer X [Fri, 20 Mar 2020 23:41:08 +0000 (01:41 +0200)]
Update Module::CoreList for 5.32.0

18 months agoBump version to 5.32.0
Sawyer X [Fri, 20 Mar 2020 23:11:56 +0000 (01:11 +0200)]
Bump version to 5.32.0

18 months agonew delta for 5.31.11
Sawyer X [Fri, 20 Mar 2020 20:42:04 +0000 (22:42 +0200)]
new delta for 5.31.11

18 months agoTick release
Sawyer X [Fri, 20 Mar 2020 20:34:43 +0000 (22:34 +0200)]
Tick release

18 months agoAdd my epigraph, minus link
Sawyer X [Fri, 20 Mar 2020 20:28:07 +0000 (22:28 +0200)]
Add my epigraph, minus link

18 months agoMerge branch 'release-5.31.10' into blead
Sawyer X [Fri, 20 Mar 2020 20:26:12 +0000 (22:26 +0200)]
Merge branch 'release-5.31.10' into blead

18 months agoadd new release to perlhist v5.31.10
Sawyer X [Fri, 20 Mar 2020 16:20:46 +0000 (18:20 +0200)]
add new release to perlhist

18 months agoperldelta cleanup
Sawyer X [Fri, 20 Mar 2020 16:05:22 +0000 (18:05 +0200)]
perldelta cleanup

18 months agoAdd obituary for DrForr...
Sawyer X [Fri, 20 Mar 2020 16:07:20 +0000 (18:07 +0200)]
Add obituary for DrForr...

18 months agoShape up perldelta, write obituary...
Sawyer X [Fri, 20 Mar 2020 15:55:43 +0000 (17:55 +0200)]
Shape up perldelta, write obituary...

18 months agofix PERL_GLOBAL_STRUCT_PRIVATE builds
David Mitchell [Fri, 20 Mar 2020 13:36:37 +0000 (13:36 +0000)]

Sprinkle some dVAR pixie dust to fix recent bitrot on that build

18 months agoregcomp.c: Update comments
Karl Williamson [Fri, 20 Mar 2020 13:37:55 +0000 (07:37 -0600)]
regcomp.c: Update comments

The previous commit expanded the possible things in these variables

18 months agoAdd named sequences to Unicode wildcard name capabilites
Karl Williamson [Fri, 20 Mar 2020 04:13:30 +0000 (22:13 -0600)]
Add named sequences to Unicode wildcard name capabilites

Prior to this commit, specifying a named sequence would result in a
mostly unhelpful fatal error message.  This makes their use legal.

This is also the beginning of allowing Unicode string properties, which
are a new thing in the (still draft) Unicode requirements for regular
expression parsing, UTS 18.  Full compliance will have to come later.

18 months agoregcomp.c: white-space only
Karl Williamson [Fri, 20 Mar 2020 04:52:38 +0000 (22:52 -0600)]
regcomp.c: white-space only

indent code that the next commit forms a block around

18 months agoregcomp.c: Add a [ to fake string only if original had one
Karl Williamson [Fri, 20 Mar 2020 04:17:58 +0000 (22:17 -0600)]
regcomp.c: Add a [ to fake string only if original had one

This code is assembling a fake string to parse, modified from the
original.  Prior to a future commit, this was only called when there was
a bracketed character class, so it made sense to unconditionally add
the bracket.  But soon this will be called when there isn't a bracket,
so one shouldn't be added.

18 months agomktables: Change named sequences to 5 digits
Karl Williamson [Fri, 20 Mar 2020 04:02:38 +0000 (22:02 -0600)]
mktables: Change named sequences to 5 digits

This makes them correspond to names for single characters, and will make
parsing easier in the next commits.

18 months agoregcomp.c: Fix misspelling
Karl Williamson [Wed, 11 Mar 2020 22:21:31 +0000 (16:21 -0600)]
regcomp.c: Fix misspelling

18 months agoDocument chained oprators in perldelta
Sawyer X [Fri, 20 Mar 2020 13:32:16 +0000 (15:32 +0200)]
Document chained oprators in perldelta

18 months agofixup to free_and_set_cop_warnings()
David Mitchell [Fri, 20 Mar 2020 09:06:57 +0000 (09:06 +0000)]
fixup to free_and_set_cop_warnings()

v5.31.9-156-g94c8b9c1f0 introduced the free_and_set_cop_warnings()
macro. It's first argument expects a COP rather than a COP*. Its usage
in S_restore_cop_warnings(() is to modify PL_cucop, but in order to pass
a COP rather than a COP*, the original commit made a local copy of
PL_curcop and ended up inadvertently updating the copy instead.

This commit changes the maco so it expects a COP*, and updates the bulk
of its callers to use &PL_compiling rather than PL_compiling, and fixes
up S_restore_cop_warnings().

The symptoms were ASAN failures in a few test scripts including
uni/parser.t and ext/XS-APItest/t/handy0*.t.

(The S_restore_cop_warnings() function was only used by
Perl__force_out_malformed_utf8_message(), so didn't cause many issues
outside of test scripts which forced such "malformed "errors).

18 months agovmsish.h: Fix missing semicolon from 2bc5f86
Craig A. Berry [Thu, 19 Mar 2020 18:10:35 +0000 (13:10 -0500)]
vmsish.h: Fix missing semicolon from 2bc5f86

18 months agoCorrect some grammar in README.linux and update it
Shlomi Fish [Wed, 22 May 2019 10:27:32 +0000 (13:27 +0300)]
Correct some grammar in README.linux and update it

Fix GH #17007

(cherry picked from commit b9677ee9a1dd1f5d79c5ab3e2e788eea65c20253)
Signed-off-by: Nicolas R <>
18 months agolib/unicore/mktables: use function signatures
Nicolas R [Wed, 11 Mar 2020 20:01:44 +0000 (14:01 -0600)]
lib/unicore/mktables: use function signatures

Also regenerate files depending on lib/unicore/mktables

    ./perl -Ilib regen/; ./perl -Ilib regen/

18 months agomodernize mkppport with signatures
Nicolas R [Wed, 11 Mar 2020 17:23:52 +0000 (11:23 -0600)]
modernize mkppport with signatures

18 months agoregen/ Add comment
Karl Williamson [Thu, 19 Mar 2020 00:35:08 +0000 (18:35 -0600)]
regen/ Add comment

18 months agoregen/ Rearrange ternary expression
Karl Williamson [Sun, 15 Mar 2020 20:14:34 +0000 (14:14 -0600)]
regen/ Rearrange ternary expression

I and Perl Best Practices agree that this syntax is hard to read.

18 months agoFile-Glob/bsd_glob.c: use PerlEnv_getenv()
Karl Williamson [Sat, 7 Mar 2020 20:01:39 +0000 (13:01 -0700)]
File-Glob/bsd_glob.c: use PerlEnv_getenv()

which has added protections beyond plain getenv()

18 months agoPerl_init_tm: Use mutex to avoid race.
Karl Williamson [Mon, 16 Mar 2020 04:17:32 +0000 (22:17 -0600)]
Perl_init_tm: Use mutex to avoid race.

This locks around localtime (and localtime_r which this call may be
translated into) which are sensitive to locale and environment changes
in their execution.

18 months agoMerge branch 'time64' into blead
Karl Williamson [Thu, 19 Mar 2020 00:09:24 +0000 (18:09 -0600)]
Merge branch 'time64' into blead

This branch refactors a portion of time64.c, simplifying and protecting
against races on threaded perls.

18 months agotime64.c: Add a branch prediction for unlikely event
Karl Williamson [Mon, 16 Mar 2020 13:42:58 +0000 (07:42 -0600)]
time64.c: Add a branch prediction for unlikely event

18 months agotime64.c: Add mutex protection
Karl Williamson [Sun, 15 Mar 2020 18:16:47 +0000 (12:16 -0600)]
time64.c: Add mutex protection

The gmtime_r() and localtime_r() functions are  not thread safe with
regards to changes in the environment and locale while executing.  This
protects them with a mutex, but only from other functions that also
participate in using that mutex.  Future commits will change everything
in the perl core to do that, but there is still a hole if some XS
writer, or alien library doesn't use the mutex.

18 months agotime64.[ch]: Inline only use of another macro
Karl Williamson [Sun, 15 Mar 2020 16:19:18 +0000 (10:19 -0600)]
time64.[ch]: Inline only use of another macro

This macro is now only used once.  It is accessible outside perl because
it is in time64.h, but isn't used in cpan.  Remove it and place its
expansion in time64.c.

Part of the expansion called another function.  That function can be
removed and the expansion simplified, since gmtime() is now
automatically converted into gmtime_r() if available and needed.

18 months agotime64.[ch]: Inline only use of a macro and fcn
Karl Williamson [Sun, 15 Mar 2020 04:34:00 +0000 (22:34 -0600)]
time64.[ch]: Inline only use of a macro and fcn

This macro is now only used once, and was the only caller of a helper
function.  Thus both can be removed and inlined, simplifying things.

Further, most of the function's functionality can be removed, since it
was an attempt to simulate localtime_r(), which is now automatically
furnished by reentrant.[ch] if needed.

18 months agotime64.c: White-space only
Karl Williamson [Sun, 15 Mar 2020 15:36:29 +0000 (09:36 -0600)]
time64.c: White-space only

Indent code blocks created by the previous commit; a few more
white-space adjustments.

18 months agotime64.c: Refactor Perl_localtime64_r()
Karl Williamson [Sat, 14 Mar 2020 20:33:05 +0000 (14:33 -0600)]
time64.c: Refactor Perl_localtime64_r()

There are two main cases in Perl_localtime64_r(), call them A and B.

Prior to this commit, it was structured

if (A) {


The problem this commit solves is that there is common stuff in codeA
and codeB that will now only be specified once.  Currently that common
stuff is minimal, and so acceptable, but the next few commits will make
the common stuff more complex, so making it be only once is helpful.

18 months agotime64.c: Store fcn return in a variable
Karl Williamson [Sat, 14 Mar 2020 20:18:56 +0000 (14:18 -0600)]
time64.c: Store fcn return in a variable

This is in preparation for it being used in more than one place

18 months agoreentr.[ch]: Add gmtime_r, localtime_r
Karl Williamson [Sun, 15 Mar 2020 20:18:53 +0000 (14:18 -0600)]
reentr.[ch]: Add gmtime_r, localtime_r

This now replaces occurrences of the non re-entrant versions of these
two functions  with the reentrant ones.

18 months agoreentr.h: Add way to see if reentrant used
Karl Williamson [Mon, 16 Mar 2020 18:00:51 +0000 (12:00 -0600)]
reentr.h: Add way to see if reentrant used

The reentrant mechanism automatically and silently replaces a given
function by its reentrant version when warranted.  Until now, there was
no direct way to test if it actually happens.  One could infer it,
possibly, but not without the potential for getting it wrong.

Now, for function foo, add #ifdef PERL_REENTR_USING_FOO_R

18 months agoreentr.h: Add clarifying comment
Karl Williamson [Mon, 16 Mar 2020 17:52:59 +0000 (11:52 -0600)]
reentr.h: Add clarifying comment

18 months agoreentr.[ch]: White-space only
Karl Williamson [Mon, 16 Mar 2020 17:13:40 +0000 (11:13 -0600)]
reentr.[ch]: White-space only

This is a follow-on to 7c1815b7942f8c7e3651d98060ca7a0760e6483c,
that adds some more white space indentation fixes

18 months agoperl.h: Add ENV_LOCALE (UN)?LOCK macros
Karl Williamson [Mon, 16 Mar 2020 03:33:19 +0000 (21:33 -0600)]
perl.h: Add ENV_LOCALE (UN)?LOCK macros

These are eventually intended to lock both the environment and locale
mutexes, but it is too late in the current development cycle to do that.
Instead these are, for now, equivalent to a plain ENV mutex.
(On many modern platforms, the locale mutex is a no-op, so not doing it
is not actually a problem.)

In the meantime, this gives significant better thread safety than what
has been in effect.

18 months agopp_match(): output regex debugging info
Karl Williamson [Thu, 5 Mar 2020 03:58:28 +0000 (20:58 -0700)]
pp_match(): output regex debugging info

This fixes #17612

This adds an inline function to pp_hot to be called to determine if
debugging info should be output or not, regardless of whether it comes
from -Dr, or from a 'use re Debug' statement

18 months agoregcomp.h: Add macro
Karl Williamson [Thu, 5 Mar 2020 03:52:57 +0000 (20:52 -0700)]
regcomp.h: Add macro

This macro is for files outside of regcomp.c/regexec.c (and
re_comp.c/re_exec.c) to have access to the Debug options.

Right now pp_match could benefit from this.

18 months agopp_match: Use 'z' length modifier to format sizes
Karl Williamson [Thu, 5 Mar 2020 03:13:27 +0000 (20:13 -0700)]
pp_match: Use 'z' length modifier to format sizes

This makes things easier to read.

18 months agoPOSIX.xs: Never pass NULL to ctermid()
Karl Williamson [Tue, 17 Mar 2020 17:39:02 +0000 (11:39 -0600)]
POSIX.xs: Never pass NULL to ctermid()

Doing so can cause races.

It is interesting that POSIX:ctermid() takes a parameter, but the
pod doesn't indicate that it does.  Prior to this commit the parameter
was ignored if and only if the platform contains a ctermid_r()
function, and hence on such platforms there was no possibility of a race
here.  The man pages I've seen for ctermid_r() indicate that it differs
from regular ctermid() only in that it will fail if the input is NULL,
and hence a race could occur if it didn't immediately fail.

The situation prior to this commit wa that if you followed the pod on a
non-ctermid_r() platform, and called this without a parameter, it would
call ctermid with NULL, creating a potential race.  This commit changes
so that a race is never possible.

18 months agoRegne reentr.c.
Karl Williamson [Wed, 18 Mar 2020 20:53:05 +0000 (14:53 -0600)]
Regne reentr.c.

Commit 727613455d53416b197154b7b3cad20fe26372bb failed to regenerate
reentr.c after changes.

18 months agoreentr.c: revise handling of several wrapped fcns
Karl Williamson [Wed, 11 Mar 2020 20:35:44 +0000 (14:35 -0600)]
reentr.c: revise handling of several wrapped fcns

Prior to this commit, the code in this function had generic variables,
like p0, and malloc'd them using void *, and then cast to what it
thought were the proper types.  This was failing on solaris g++, because
of the stricter casting rules in C++.

This commit actually simplifies the code, by getting rid of the generic
stuff, and for each group of related functions, declares the appropriate
names for the variables, and mallocs them using the correct type as
expressed in the __DATA__ section of regen/  The casting is
eliminated, except for one case for gethostbyaddr().  Tony Cook pointed
out that the 2001 POSIX standard used a type name for this that may be
shorter than Size_t.  This could be a potential issue, but not on the
platforms tested as of now.

And this fixes #17482, so works where the previous didn't.

18 months agoreentr.c: Handle getspnam()
Karl Williamson [Wed, 11 Mar 2020 18:24:33 +0000 (12:24 -0600)]
reentr.c: Handle getspnam()

This has never worked to increase the buffer size if necessary.
Apparently the default has always been big enough.  But this commit
fixes it to retry if too small.

I don't think there is a way to write tests for this.  getspnam is
called only as a small part of pp_gpwent, and is not part of the API,
and is called only when run as root.

I did test it on my box, with gdb, starting with a buffer size of 1, and
single stepping and observing that it works as I expected.

18 months agoreentr.c: Use keywords, not ops
Karl Williamson [Wed, 11 Mar 2020 18:05:01 +0000 (12:05 -0600)]
reentr.c: Use keywords, not ops

The parameter to this function is a string containing the name of the
wrapped function.  Prior to this commit, it was assumed, without
checking, that PL_op->op_type corresponded to this name.  This
assumption can't be always correct because at least one of the wrapped
functions doesn't have an op, getspnam.  That means it never would have
worked for that function to increase its buffer size.  When I was
examining this some years ago (and didn't follow up until now), ISTR
that there were other cases where the correspondence was wrong, but I
couldn't reproduce that now.

There is no easy conversion from string to OP code, but there is from
string to keyword number.  This commit changes to use that conversion
function, and switches based on the keyword number.  A later commit
fixes getspnam.

18 months agofixup to "avoid identical stack traces" - try 2
David Mitchell [Thu, 12 Mar 2020 14:14:24 +0000 (14:14 +0000)]
fixup to "avoid identical stack traces" - try 2

GH #15109, #17567

[ this commit was originally applied as v5.31.9-121-gfb8188b84d, but was
quickly reverted by v5.31.9-124-g6311900a66. I'm now -re-applying it,
but with a 'SAVEFREEOP(PL_curcop)' added, which was missing from the
original commit. ]

My original fix for this issue, v5.31.6-141-gf2f32cd638
made a shallow copy of &PL_compiling. However, for non-default
warning bits, this made two COPs share the malloced() cop_warnings,
and bad things ensured. In particular this was flagged up in:

    GH #17567: "BBC: AYOUNG/OpenVZ-0.01.tar.gz"

The fix in this commit is to do a deep copy of the COP using

18 months agoFix pod errors
Karl Williamson [Tue, 17 Mar 2020 03:13:39 +0000 (21:13 -0600)]
Fix pod errors

introduced by cd7ac46508e1b2b346c339417237ef487bf59c74

18 months agoperlre: Note savepv() allocations need to be freed
Karl Williamson [Mon, 16 Mar 2020 20:27:49 +0000 (14:27 -0600)]
perlre: Note savepv() allocations need to be freed

18 months agoswitch_category_locale_to_template: Fix use-after-free under -DLv
Dagfinn Ilmari Mannsåker [Mon, 16 Mar 2020 19:40:00 +0000 (19:40 +0000)]
switch_category_locale_to_template: Fix use-after-free under -DLv

Coverity CID 288709

18 months agoDynaloader: Add, fix comments
Karl Williamson [Sat, 7 Mar 2020 19:42:23 +0000 (12:42 -0700)]
Dynaloader: Add, fix comments

18 months agoiperlsys.h: White-space only
Karl Williamson [Sun, 8 Mar 2020 00:02:37 +0000 (17:02 -0700)]
iperlsys.h: White-space only

18 months agoAdd macro to free and set cop_warnings
Nicolas R [Tue, 10 Mar 2020 17:14:04 +0000 (11:14 -0600)]
Add macro to free and set cop_warnings

This is avoiding the boilerplate to free
the cop_warning string when setting it.