This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
2 years agoperl_alloc() wants zeroed memory so should use calloc()
Nicholas Clark [Fri, 17 Sep 2021 19:43:51 +0000 (19:43 +0000)]
perl_alloc() wants zeroed memory so should use calloc()

The previous code

1) allocated memory with PerlMem_malloc()
2) passed the pointer to S_init_tls_and_interp()
3) called Zero() or ZeroD()
4) optionally invoked INIT_TRACK_MEMPOOL()
5) returned the pointer

ZeroD() and Zero() are equivalent, apart from the return value of the
expression.

The layers of functions and macros obscured what what was actually
happening, and what the ordering dependencies are:

* S_init_tls_and_interp() uses only the address of the pointer
* Zero() zeros the memory
* Only INIT_TRACK_MEMPOOL() touches the contents
* all the "memory wrap" macros inside the other macros can't "trigger"

Hence the order of Zero() and S_init_tls_and_interp() can be swapped,
at which point Zero() immediately follows malloc(), meaning that the two
should be be replaced with calloc().

This simplifies the function considerably.

2 years agoTest ASAN with -DDEBUGGING (and so also with assertions enabled)
Nicholas Clark [Tue, 21 Sep 2021 13:20:06 +0000 (13:20 +0000)]
Test ASAN with -DDEBUGGING (and so also with assertions enabled)

Make it clear in the earlier comment about -DDEBUGGING that it was
referencing the "linux" job, not the entire file.

2 years agoTest a macOS threaded shared-library build too
Nicholas Clark [Fri, 17 Sep 2021 13:15:10 +0000 (13:15 +0000)]
Test a macOS threaded shared-library build too

2 years agoTest clang's ASAN as well as gcc's ASAN
Nicholas Clark [Fri, 17 Sep 2021 10:56:37 +0000 (10:56 +0000)]
Test clang's ASAN as well as gcc's ASAN

On the GH virtual machine, gcc's ASAN appears to be slightly buggy, as the
`-Accflags=-DPURIFY` job is causing cpan/File-Path/t/Path.t to reliably
SEGV after passing all 167 subtests:
    Tracer caught signal 11: addr=0x0 pc=0x7ff95dfaa8b0 sp=0x7ff95a2a6ce0
    LeakSanitizer has encountered a fatal error.

I can't replicate this on machines I have access to, which makes it rather
hard to debug. Hence side-step the issue by running this test with clang
instead, so that we also test with clang's ASAN implementation.

We still test with gcc's ASAN in one of the PERL_UNICODE jobs.

2 years agoRun t/TEST directly on cygwin in the CI workflow
Nicholas Clark [Mon, 20 Sep 2021 06:57:12 +0000 (06:57 +0000)]
Run t/TEST directly on cygwin in the CI workflow

`make -j2 test` causes make to re-run the build in all the extension
directories, which takes about 40 seconds on the GH servers - ie this alone
is roughly 1% of the total test time.

Hence change the build target to `test_prep`, the Makefile pre-requisite for
testing, and then run t/TEST.pl directly with the same environment as the
Makefile and ./runtests would have set up. As we already set
PERL_SKIP_TTY_TEST=1 in the global environment we don't have anything else
to set up.

2 years agoChange all LD_LIBRARY_PATH setup from '.' to `pwd`
Nicholas Clark [Mon, 20 Sep 2021 11:17:40 +0000 (11:17 +0000)]
Change all LD_LIBRARY_PATH setup from '.' to `pwd`

The previous commit added various new lines that set LD_LIBRARY_PATH=`pwd`,
whereas the existing lines that set LD_LIBRARY_PATH set it to '.'.

LD_LIBRARY_PATH needs to be set to the build directory to run an uninstalled
perl binary *if* that binary is built with a shared perl library. It's not
needed for the default configuration, but to simplify the test definitions we
were doing it always.

In turn, LD_LIBRARY_PATH doesn't need to be set to an *absolute* path if all
that is invoked is the perl binary - it doesn't change directory, and it
does shell out to itself, hence setting LD_LIBRARY_PATH=. is just fine here.

Running the regression tests *does* involve changing directory before
invoking perl, so LD_LIBRARY_PATH needs to be set to an absolute path there.
Running `./perl -Ilib -V` doesn't change directory (or shell out) so '.'
was good enough.

There's no real harm in also invoking `pwd` to get an absolute path here, so
do this instead of just coding '.', as the consistency makes the workflow
easier to read - you don't get distracted wondering "Why are these
different, and is that a bug?"

2 years agoRun `./perl t/harness` directly in the CI workflow
Nicholas Clark [Fri, 17 Sep 2021 10:49:39 +0000 (10:49 +0000)]
Run `./perl t/harness` directly in the CI workflow

`make -j2 test_harness` causes make to re-run the build in all the extension
directories, which can take 20 seconds even on fast server hardware. Hence
change the build target to `test_prep`, the Makefile pre-requisite for
testing, and then run t/harness directly with the same environment as the
Makefile and ./runtests would have set up. As we already set
PERL_SKIP_TTY_TEST=1 in the global environment we don't have anything else
to set up.

Keep the 'linux-i386' and 'install' jobs on the regular `test` and
`test_harness` targets to ensure we still cover them.

2 years agoTest `make install` in the GH workflow
Nicholas Clark [Fri, 17 Sep 2021 10:01:12 +0000 (10:01 +0000)]
Test `make install` in the GH workflow

2 years agoThe CI workflow needs some test builds without -DDEBUGGING
Nicholas Clark [Fri, 17 Sep 2021 09:51:18 +0000 (09:51 +0000)]
The CI workflow needs some test builds without -DDEBUGGING

2 years agoPERL_UNICODE= and LANG= can't be set as Configure arguments
Nicholas Clark [Fri, 17 Sep 2021 09:40:25 +0000 (09:40 +0000)]
PERL_UNICODE= and LANG= can't be set as Configure arguments

The intent is to test with non-C locales and non-default Unicode handling,
but to do this the values need to be set as environment variables for the
test (and build - occasionally bugs are not exposed by the testsuite).

Configure happily accepts anything on the command line, and records all its
command line arguments in config.sh (and hence also within %Config::Config).
But nothing acts on them.

It's easier to set these in a separate workflow job (and test only a couple)
rather than creating a second environment matrix in this job, and hence
test $m * $n combinations.

Unfortunately the GH test machines only have the locales C, C.UTF-8, POSIX
and en_US.utf8, so we can't easily test anything more "interesting" than
en_US.utf8.

2 years agoCI tests for PERL_UNICODE="" with a UTF-8 locale
Nicholas Clark [Fri, 17 Sep 2021 08:32:21 +0000 (08:32 +0000)]
CI tests for PERL_UNICODE="" with a UTF-8 locale

2 years agoIn the Linux workflows use MALLOC_PERTURB_ and MALLOC_CHECK_
Nicholas Clark [Fri, 17 Sep 2021 08:20:12 +0000 (08:20 +0000)]
In the Linux workflows use MALLOC_PERTURB_ and MALLOC_CHECK_

MALLOC_CHECK_=3 causes glibc to abort if it detects malloc errors.
Specifically, 3 will be "Print detailed error message, stack trace, and
memory mappings, and abort the program."

MALLOC_PERTURB_=254 will cause newly allocated memory to be set to non-zero
values, and freed memory to be set to the given non-zero value.

See `man mallopt`

Intentionally only setting these for the build and test steps, but not the
Configure step, to see if we can later expose bugs caused by bad probes.
If we set it for Configure, the abort this triggers might simply cause a
probe to be silently failed, and we could miss problems.

2 years agoTest ASAN builds with and without -DPURIFY
Nicholas Clark [Fri, 17 Sep 2021 06:57:10 +0000 (06:57 +0000)]
Test ASAN builds with and without -DPURIFY

Also we can fail-fast on ASAN to save some resources. Likely if one ASAN
build fails, the others won't tell us about different problems.

2 years agoWorkflows should `make test_harness` to get parallel testing
Nicholas Clark [Fri, 17 Sep 2021 06:48:42 +0000 (06:48 +0000)]
Workflows should `make test_harness` to get parallel testing

`make test` uses t/TEST which always runs tests sequentially.
TEST_JOBS only makes sense with t/harness, which is run by the
`test_harness` target.

2 years agoAll workflow jobs use the same env: so move it to the top level
Nicholas Clark [Fri, 17 Sep 2021 06:43:39 +0000 (06:43 +0000)]
All workflow jobs use the same env: so move it to the top level

Also nothing references $ENV{WORKSPACE} so no need to set this. Documentation
for actions/checkout implies that it is reading from $GITHUB_WORKSPACE.

2 years agoA prototype CI job to build with Address Sanitizer
Nicholas Clark [Thu, 16 Sep 2021 19:49:51 +0000 (19:49 +0000)]
A prototype CI job to build with Address Sanitizer

Whilst this *will* detect various dangerous mistakes involving bad memory
accesses, it's far more likely to spot if changes create memory leaks.

2 years agoAdd a CI job to confirm that minitest keeps passing
Nicholas Clark [Thu, 16 Sep 2021 19:32:15 +0000 (19:32 +0000)]
Add a CI job to confirm that minitest keeps passing

Currently minitest passes - let's keep it that way.

minitest might feel like makework, until one makes a seemingly innocent
change that breaks the build in "inconceivable" ways and it's no longer
even possible to get to the point of being able to run `make test`.

2 years agoAdd "missing" descriptions to testsuite.yml
Nicholas Clark [Thu, 16 Sep 2021 19:16:11 +0000 (19:16 +0000)]
Add "missing" descriptions to testsuite.yml

If it's worth doing, it's worth overdoing.

2 years agoAdd comments describing how PVLVs store REGEXPs by reference
Nicholas Clark [Thu, 23 Sep 2021 12:32:33 +0000 (12:32 +0000)]
Add comments describing how PVLVs store REGEXPs by reference

2 years agoDon't leak in hv_common when croaking about PL_strtab
Nicholas Clark [Sat, 11 Sep 2021 10:47:10 +0000 (10:47 +0000)]
Don't leak in hv_common when croaking about PL_strtab

hv_common can perform read-only actions on PL_strtab, but not write actions.
The code that detects this and croaks had been just after the allocation of
a new HE *, and hence was leaking it. Re-order the code to avoid the leak.

The leak usually wasn't noticeable as HEs are allocated from arenas, and
arenas are correctly freed during full destruction. However, building with
-DPURIFY replaces arenas with individual allocations, making this leak
visible. It's unlikely to have been hit by any production code, but it was
causing leaks during the regression tests.

Also change embed.fnc so that S_new_HE's prototype is not declared under
-DPURIFY, as the static function itself is not defined in this case. This
fixes a compiler warning.

2 years agoAvoid leaking a scalar body after REGEXP to PVLV assignment
Nicholas Clark [Sat, 11 Sep 2021 09:23:37 +0000 (09:23 +0000)]
Avoid leaking a scalar body after REGEXP to PVLV assignment

PVLV scalars are used to implement various obscure features of perl, such as
elements in tied hashes and hash lookups used as function parameters. To
make these work, PVLVs must be capable of holding all scalar types. First
class REGEXPs are larger than PVLVs, hence there is special case code to
attach REGEXP bodies to PVLVs, for code that both dereferences a regex object
and then assigns that value to a PVLV scalar. This was first implemented in
Oct 2012 by commit 8d919b0a35f2b57a:
    Allow regexp-to-pvlv assignment

and improved in July 2017 with commit df6b4bd56551f2d3:

It turns out that the implementation would leak a scalar body, for the
"normal" use case (of this obscure feature). This wasn't noticed for two
reasons

1) bodies are allocated from arenas, and arenas are correctly freed during
   full destruction.
2) the body is not leaked if the the PVLV scalar is then modified

The regression tests added by commit 8d919b0a35f2b57a were also testing
the corner case of concatenating to one of these values - ie that
sv_force_normal_flags() handled unwinding the special cases correctly.
To avoid code duplication, the tests added by that commit caused all PVLV
scalars to be passed to sv_force_normal_flags(), so didn't actually test
regular destruction of such scalars.

The tests added in Aug 2017 by commit 622c613e12cef84c:
    PVLV-as-REGEXP: avoid PVX double free

    With v5.27.2-30-gdf6b4bd, I changed the way that PVLVs store a regexp
    value (by making the xpv_len field point to a regexp struct). There was a
    bug in this, which caused the PVX buffer to be double freed.

    Several REGEXP SVs can share a PVX buffer. Only one of them will have a
    non-zero xpv_len field, and that SV gets to free the buffer.

    After the commit above, the non-zero xpv_len was triggering an extra free.

    This was showing up in smokes as failures in re/recompile.t when invoked
    with PERL_DESTRUCT_LEVEL=2 (which t/TEST does).

were actually the first to expose this bug, even though it had been present
since 2012.

The bug is only visible with a full leak test (eg valgrind --leak-check=full
or an ASAN build) with -DPURIFY (to disable arenas), hence why it hasn't
been noticed.

2 years agoIn Perl_gp_free() use PL_tmps_stack to avoid freeing glob entries immediately.
Nicholas Clark [Fri, 2 Jul 2021 09:55:00 +0000 (09:55 +0000)]
In Perl_gp_free() use PL_tmps_stack to avoid freeing glob entries immediately.

Typeglob assignment causes the current GP to be freed, and hence any package
variables it contains. As Perl's (data) stack is not reference counted, SVs
put on it are assumed to be owned by something else. For package variables,
this assumed owner is the typeglob. Hence if a single statement contains
both assignment to a typeglob and use of one of its variables, the
interpreter can read garbage (with all the usual explosive consequences).

This is yet another manifestation of "the stack is not reference counted",
and whilst troubling from a correctness perspective, can't be exploited
unless one can already run arbitrary code, in which case any attacker has
already won.

Whilst this problematic code doesn't turn up very often in real programs,
let alone hot paths, it is found quite often by researchers running
automated fuzzers. Previously these programs would trigger errors, that the
researchers would (legitimately) report, and then we would spend time
figuring out that the cause was "stack not reference counted" and so not a
dangerous security hole. This consumed a lot of researcher time, our time,
and prevents "interesting" security holes being uncovered.

Hence add code to use the temps stack to paper over the lack of stack
reference counting in this specific case. This should avoid a lot of time
spent on assessing and responding to legitimate but uninteresting security
reports, at a small cost in code complexity.

2 years agoFree tied hash iterator state immediately at the `untie` call
Nicholas Clark [Tue, 24 Aug 2021 16:15:51 +0000 (16:15 +0000)]
Free tied hash iterator state immediately at the `untie` call

Previously the state was only freed at the point when the hash was iterated
again, or re-tied, or destroyed.

This shouldn't make any difference to sane code, but the change can be
detected with suitably pathological pure-Perl code, so someone might just
(unwisely) be relying on this undocumented implementation detail.

2 years agoA test for the order of untie/iterator state interaction
Nicholas Clark [Tue, 24 Aug 2021 15:32:32 +0000 (15:32 +0000)]
A test for the order of untie/iterator state interaction

This is not intended as a test of *correctness*. The precise ordering of all
the events here is observable by code on CPAN, so potentially some of it
will inadvertently be relying on it (and likely not in any regression test).
Hence this "test" here is intended as a way to alert us if any core code
change has the side effect of altering this observable behaviour, so that we
can document it in the perldelta.

2 years agoTest the interaction of of tie/untie and hash iterators
Nicholas Clark [Thu, 16 Sep 2021 18:18:53 +0000 (18:18 +0000)]
Test the interaction of of tie/untie and hash iterators

This is not intended as a test of *correctness*. This behaviour is
observable by code on CPAN, so potentially some of it will inadvertently be
relying on it (and likely not in any regression test). Hence this "test"
here is intended as a way to alert us if any core code change has the side
effect of alerting this observable behaviour.

2 years agoUse fabs/fabsl/fabsq for NVs in pp_abs.
TAKAI Kousuke [Wed, 27 Jan 2021 14:53:48 +0000 (23:53 +0900)]
Use fabs/fabsl/fabsq for NVs in pp_abs.

In many floating point formats, fabs*() are rather simple operations
such as just clearing the sign bit, and will be slightly faster
than a conditional negation (especially with optimizing compilers).

2 years agoDon't try to Sv[PI]V() on an undef index SV in find_uninit_var() 19148/head
Tony Cook [Wed, 22 Sep 2021 01:47:55 +0000 (11:47 +1000)]
Don't try to Sv[PI]V() on an undef index SV in find_uninit_var()

When trying to evaluate:

  $x{$y}

or

  $x[$y]

where both the index and the hash or array entry was undefined,
when trying to report the entry as uninitialised, find_uninit_var()
would try to get the string or numeric value of the index,
recursively trying to produce a warning.

This would end up overflowing the stack, producing a segmentation fault.

Fixes #19147.

2 years agoNothing changed in SIGINFO for OpenBSD 7.0
Andrew Hewus Fresh [Tue, 21 Sep 2021 02:21:10 +0000 (19:21 -0700)]
Nothing changed in SIGINFO for OpenBSD 7.0

We'll check back in five years for OpenBSD 8.0 unless someone notices a
fix before then.

2 years agoPrep Module::CoreList for the 5.35.5 release
Matthew Horsfall [Tue, 21 Sep 2021 12:15:03 +0000 (08:15 -0400)]
Prep Module::CoreList for the 5.35.5 release

2 years agoIn Perl_hv_iternext_flags() move a variable to a tighter scope
Nicholas Clark [Tue, 21 Sep 2021 07:03:34 +0000 (07:03 +0000)]
In Perl_hv_iternext_flags() move a variable to a tighter scope

`xhv` was added to avoid repeated dereferences from the HV head in June 2001
as part of commit cbec93472053303a:
    Revert #10656 for performance reasons but leave in the
    use of Hv*() macros -- in comments, so that grepping the
    source is easier, from Abhijit.  (Also add the ENV_HV_NAME speedup
    suggested by Sarathy, also by Abhijit.)

Most uses were eliminated in May 2005 by commit bfcb351493b97935:
    Move hv_name, hv_eiter and hv_riter into a new aux structure.
    Provide (more efficient) _get and _set macros.
    Adjust the core to use them.

and commit 7b2c381cf37e4e46:
    Move the xpv_pv/xrv_rv member into the SV head, in a union with
    IV and UV. Avoid allocating a body for IVs and RVs.

The only other read of `xhv` was eliminated in June 2005 by commit
b79f7545f218479c:
    Store the xhv_aux structure after the main array.
    This reduces the size of HV bodies from 24 to 20 bytes on a 32 bit
    build. It has the side effect of defined %symbol_table:: now always
    being true. defined %hash is already deprecated.

After that change xhv remained, saving the first deference, but it was
still dereferenced each time within a loop to read `xhv_max`.

Ideally that commit would have made this change - replace `xhv` with a
single lookup of HvMAX() in the scope where it is needed.

2 years ago`make distclean` should delete `makedepend_file`
Nicholas Clark [Tue, 21 Sep 2021 08:35:03 +0000 (08:35 +0000)]
`make distclean` should delete `makedepend_file`

2 years agoMerge branch 'perlgov-omnibus-amendments' into blead
Ricardo Signes [Tue, 21 Sep 2021 02:38:48 +0000 (22:38 -0400)]
Merge branch 'perlgov-omnibus-amendments' into blead

2 years agoperlgov: replace "administer" with "organize"
Ricardo Signes [Sat, 21 Aug 2021 14:29:35 +0000 (10:29 -0400)]
perlgov: replace "administer" with "organize"

Other parts of perlgov forbid PSC members from being vote
administrators, so using "administer" here was confusing.

2 years agoperlgov: clarify time frame for newly Term Election
Ricardo Signes [Sat, 29 May 2021 16:46:37 +0000 (12:46 -0400)]
perlgov: clarify time frame for newly Term Election

2 years agoperlgov: changes related to handling uncontested elections
Ricardo Signes [Thu, 15 Apr 2021 18:39:34 +0000 (14:39 -0400)]
perlgov: changes related to handling uncontested elections

2 years agoperlgov: allow deferral of Special Election
Ricardo Signes [Thu, 15 Apr 2021 02:25:25 +0000 (22:25 -0400)]
perlgov: allow deferral of Special Election

When, for example, there is a need for Special Election near the
date of an upcoming Term Election.

2 years agoUpdate release_announcement_template.txt year for the next poor soul
Matthew Horsfall [Mon, 20 Sep 2021 20:35:50 +0000 (16:35 -0400)]
Update release_announcement_template.txt year for the next poor soul

2 years agoUpdate Module::CoreList for v5.35.5
Matthew Horsfall [Mon, 20 Sep 2021 20:25:26 +0000 (16:25 -0400)]
Update Module::CoreList for v5.35.5

2 years agoBump versions from v5.35.4 to v5.35.5
Matthew Horsfall [Mon, 20 Sep 2021 20:16:11 +0000 (16:16 -0400)]
Bump versions from v5.35.4 to v5.35.5

2 years agonew perldelta for v5.35.5
Matthew Horsfall [Mon, 20 Sep 2021 20:09:51 +0000 (16:09 -0400)]
new perldelta for v5.35.5

2 years agoCheck off 5.35.4 in release_schedule.pod
Matthew Horsfall [Mon, 20 Sep 2021 19:59:20 +0000 (15:59 -0400)]
Check off 5.35.4 in release_schedule.pod

2 years agoUpdate epigraphs for 5.35.4 release
Matthew Horsfall [Mon, 20 Sep 2021 19:58:59 +0000 (15:58 -0400)]
Update epigraphs for 5.35.4 release

2 years agoMerge branch 'release-5.35.4' into blead
Matthew Horsfall [Mon, 20 Sep 2021 19:52:18 +0000 (15:52 -0400)]
Merge branch 'release-5.35.4' into blead

2 years agoAdd Olaf Alders to AUTHORS file
Olaf Alders [Mon, 20 Sep 2021 17:05:55 +0000 (13:05 -0400)]
Add Olaf Alders to AUTHORS file

2 years agoUpdate comment in POSIX::import()
Olaf Alders [Mon, 20 Sep 2021 15:53:38 +0000 (11:53 -0400)]
Update comment in POSIX::import()

This removes the use of grandfather as a verb. See #18830 for initial
discussion.

2 years agoadd new release to perlhist v5.35.4
Matthew Horsfall [Mon, 20 Sep 2021 18:53:53 +0000 (14:53 -0400)]
add new release to perlhist

2 years agoFinalize perldelta
Matthew Horsfall [Mon, 20 Sep 2021 18:49:47 +0000 (14:49 -0400)]
Finalize perldelta

2 years agoperldelta: Update modules list
Matthew Horsfall [Mon, 20 Sep 2021 18:46:35 +0000 (14:46 -0400)]
perldelta: Update modules list

2 years agoperldelta: Acknowledge thyself
Matthew Horsfall [Mon, 20 Sep 2021 18:45:17 +0000 (14:45 -0400)]
perldelta: Acknowledge thyself

2 years agoUpdate Module::CoreList for 5.35.4
Matthew Horsfall [Mon, 20 Sep 2021 18:39:07 +0000 (14:39 -0400)]
Update Module::CoreList for 5.35.4

2 years agoPrepare perldelta for upcoming v5.35.4 release
Matthew Horsfall [Mon, 20 Sep 2021 18:25:43 +0000 (14:25 -0400)]
Prepare perldelta for upcoming v5.35.4 release

2 years agoperldelta for 983d5bee62
James E Keenan [Mon, 20 Sep 2021 14:21:50 +0000 (14:21 +0000)]
perldelta for 983d5bee62

2 years agoUnicode-Collate: synch with CPAN version 1.31
Tomoyuki Sadahiro [Mon, 20 Sep 2021 14:18:10 +0000 (14:18 +0000)]
Unicode-Collate: synch with CPAN version 1.31

2 years agoMove all the code that deletes the hash entry into one place
Nicholas Clark [Mon, 26 Jul 2021 09:43:13 +0000 (09:43 +0000)]
Move all the code that deletes the hash entry into one place

Move the code that removed the entry from the hash ahead of all the code
that post-processes that entry to update method caches.

The entry is now completely deleted from the hash before any needed MRO
related logic is triggered, and the code that is specific to the chosen hash
table implementation is now untangled from the MRO code.

2 years agoMerge the two `d_flags & G_DISCARD` tests in hv_delete_common()
Nicholas Clark [Mon, 26 Jul 2021 09:28:15 +0000 (09:28 +0000)]
Merge the two `d_flags & G_DISCARD` tests in hv_delete_common()

Read from HeVAL() once, and move the call to sv_2mortal() later.

2 years agoCall mro_method_changed_in() later in hv_delete_common()
Nicholas Clark [Sun, 25 Jul 2021 20:12:25 +0000 (20:12 +0000)]
Call mro_method_changed_in() later in hv_delete_common()

Move the call as late as possible - just before the deleted hash key is
freed if G_DISCARD is set. In particular, move it *after* the HE is
freed.

Move the code that sets HeVAL() to &PL_sv_placeholder into the if block that
handles restricted hashes - no need to set this on normal hashes, as the
structure is about to be freed anyway.

2 years agoRemove descriptions of deleted "Panics" from perldiag.pod
Nicholas Clark [Wed, 15 Sep 2021 09:20:31 +0000 (09:20 +0000)]
Remove descriptions of deleted "Panics" from perldiag.pod

"Bad hash" and "Can't modify nonexistent substring" were removed in March
2015 as part of commit 3dc78631ef832e5b:
    don't test non-null args

"Can't check filesystem of script "%s" for nosuid"
and "Can't stat script "%s"" were removed in Jan 2009 as part of
commit cc69b689ee7c2745:
    suidperl goes.

"do_study: out of memory" was removed in May 2012 as part of commit
32f0ea87169ccae6:
    Delete the contents of pp_study

"Null realloc" was removed in June 1998 as part of commit 7614df0c0f0d0458:
    added patch, undo earlier workaround
            Subject: Re: Why does saferealloc(NULL,size) croak? [PATCH] against _66
            Message-ID: <35831f69.4975644@smtp1.ibm.net>

"NULL regexp argument" was removed in April 2007 as part of commit
3ab4a224eb8d34c0:
    Re: [PATCH (incomplete)] Make regcomp use SV* sv, instead of char* exp, char* xend
    Message-ID: <51dd1af80704211430m6ad1b4afy49b069faa61e33a9@mail.gmail.com>

"panic: do_subst" was renamed in Dec 2000 as part of commit 2269b42e02cee868:
    Make some panic messages a bit more logical.

"panic: do_trans_%" was removed in Nov 2019 as part of commit f34acfecc286:
    Reimplement tr/// without swashes

"panic: last, type=%u" was removed in May 2015 as part of commit
d3e5e568e186db1f:
    pp_last: only handle loop context types

"panic: leave_scope clearsv" was removed in April 1999 as part of commit
6fc9266916f08dac:
    remove duplicate code and an extra branch in sv_setsv() and
    other hot code by making SvTHINKFIRST() think about FAKE SVs

"panic: strxfrm() gets absurd - a => %u, ab => %u" was removed in April
2016 as part of commit 79f120c89a6e1237:
    Change calculation of locale collation coefficients

2 years agoPrefix "unexpected constant lvalue entersub" with "panic: "
Nicholas Clark [Wed, 15 Sep 2021 08:27:22 +0000 (08:27 +0000)]
Prefix "unexpected constant lvalue entersub" with "panic: "

In Sep 1999 commit cd06dffe59d6 added various "internal error" croak()s:
    initial implementation of lvalue subroutines (slightly fixed
    version of patch suggested by Ilya Zakharevich, which in turn
    is based on the one suggested by Tuomas J. Lukka <lukka@iki.fi>)

One was "panic: unexpected lvalue entersub entry via type/targ %ld:%ld"
Another "Unexpected constant lvalue entersub entry via type/targ %ld:%ld"

Prefix the latter with "panic: " to make it consistent.

2 years agowin32: regen config_H.(gc|vc)
Tomasz Konojacki [Fri, 17 Sep 2021 22:34:42 +0000 (00:34 +0200)]
win32: regen config_H.(gc|vc)

2 years agoTest that for's iterator aliases the iterated list
Nicholas Clark [Wed, 15 Sep 2021 18:43:22 +0000 (18:43 +0000)]
Test that for's iterator aliases the iterated list

2 years agoAdd strict and warnings to t/op/for.t
Nicholas Clark [Wed, 15 Sep 2021 17:42:59 +0000 (17:42 +0000)]
Add strict and warnings to t/op/for.t

strict subs and refs, but not strict vars, because it's obvious that some
tests are explicitly about package variables, but it's not obvious whether
what they are testing is sensitive to rewriting the variables with full
package names.

Also convert it to done_testing(), and add a call to set_up_inc().

2 years agoext/B/t/o.t shouldn't generate the same test module each run.
Nicholas Clark [Tue, 14 Sep 2021 09:17:06 +0000 (09:17 +0000)]
ext/B/t/o.t shouldn't generate the same test module each run.

Extract its test module B::success into a real file, and eliminate lots
of runtime path creation, file creation and file deletion complexity.

2 years agoRemove all "configured without perlio" test SKIPs from ext/PerlIO-*
Nicholas Clark [Tue, 14 Sep 2021 08:41:36 +0000 (08:41 +0000)]
Remove all "configured without perlio" test SKIPs from ext/PerlIO-*

Also fix one skip that should have been for B, not PerlIO.

2 years agoRemove former SKIP blocks in ext/B/t/concise.t and re-indent
Nicholas Clark [Thu, 16 Sep 2021 10:40:27 +0000 (10:40 +0000)]
Remove former SKIP blocks in ext/B/t/concise.t and re-indent

2 years agoRemove all "configured without perlio" test SKIPs from ext/B
Nicholas Clark [Tue, 14 Sep 2021 08:02:05 +0000 (08:02 +0000)]
Remove all "configured without perlio" test SKIPs from ext/B

It's not been possible to build perl without perlio since v5.16.0

Also remove comments relating to code fixups that were removed in Oct 2006
by commit ab7e0f544dbf50e3:
    [patch] simplify optree test support
    Message-ID: <4545220A.6060500@gmail.com>

Remove redundant `use Config;`s, and correct one (intended) %Config::Config
lookup where Config was only required, and hence %Config was not imported.

2 years agoutf8.h: Rmv redundant asserts
Karl Williamson [Thu, 16 Sep 2021 12:41:09 +0000 (06:41 -0600)]
utf8.h: Rmv redundant asserts

These macros asserted both that the passed in parameter occupied no more
than a byte, and that it wasn't a pointer.  But pointers occupy more
than a byte, so if it passes the first check, meaning it occupies only a
byte, it will necessarily pass the second, making that check unnecessary.

2 years agoMerge branch 'smoke-me/jkeenan/g++10-build-time-warnings-20210913' into blead
James E Keenan [Thu, 16 Sep 2021 11:53:54 +0000 (11:53 +0000)]
Merge branch 'smoke-me/jkeenan/g++10-build-time-warnings-20210913' into blead

2 years agoKeep lines under 80 characters 19132/head
James E Keenan [Wed, 15 Sep 2021 17:21:20 +0000 (17:21 +0000)]
Keep lines under 80 characters

Per hv review in
https://github.com/Perl/perl5/pull/19132#issuecomment-920155495.

2 years agog++10 -Wparentheses build-time warnings
James E Keenan [Mon, 13 Sep 2021 23:35:14 +0000 (23:35 +0000)]
g++10 -Wparentheses build-time warnings

Two build-time warnings appeared when building with g++10 as compared
with g++9.  Both were:

"suggest parentheses around assignment used as truth value"

2 years agoAvoid a use-after-free deleting 8-bit keys from stashes
Nicholas Clark [Mon, 26 Jul 2021 07:32:46 +0000 (07:32 +0000)]
Avoid a use-after-free deleting 8-bit keys from stashes

This code path only affects symbol tables, and can't be reached by regular
Perl code. It is only reachable using the XS API to delete a key from a
stash where the key was in the 8-bit range but passed in UTF-8 encoded.

This has been in the code since it was added in Oct 2010 by commit
35759254f69c7bfa:
    Rename stashes when they move around

Also there is no need to call SvPV() on keysv in S_hv_delete_common() as
its caller has always already done this. This entire code is not KISS.

2 years agoSimplify the code related to prime_env_iter().
Nicholas Clark [Sun, 12 Sep 2021 08:44:52 +0000 (08:44 +0000)]
Simplify the code related to prime_env_iter().

Of the platforms that define DYNAMIC_ENV_FETCH, prime_env_iter() is only
needed on VMS, so only call it on VMS. Previously we defined a dummy stub on
Win32 (with PERL_IMPLICIT_SYS defined), and did something different again
for __riscos__.

Remove the dummy definition for win32, and change the conditional compilation
to only call prime_env_iter() on VMS. This removes a call to mg_find() on
Win32, which likely can't be optimised away, as the compiler cannot know that
it has no side effects.

Because`iter` points to a structure immediately after of HvARRAY(), it needs
updating if HvARRAY() has moved because it has been expanded.

Code was added for VMS in Aug 2005 to address this bug with commit
03026e68943709ca:
    [patch@25334] hv.c vms environment fix.
    From: "John E. Malmberg" <wb8tyw@qsl.net>
    Message-ID: <4310F552.8050401@qsl.net>

see https://www.nntp.perl.org/group/perl.perl5.porters/2005/08/msg104261.html

However, the comment added in that code wasn't entirely accurate. The
iteration count doesn't need to be *reset* because prior to that first call
to prime_env_iter() there would be no entries in the hash. In fact, the
iterator *had* to be in its "reset" state - entry == NULL - to enter the
if block. Also, as prime_env_iter() only adds hash values but does not
change the hash's iterator state, it can't change iter->xhv_eiter. Hence
there's no need to re-read *that* value, is it will still be NULL.

Hence the only action needed is to re-initialise iter from HvAUX(), as the
structure it needs to point to has likely been moved in memory by the hash
stores performed by prime_env_iter().

2 years agoTest that %ENV iteration with prime_env_iter() is consistent
Nicholas Clark [Sun, 12 Sep 2021 08:17:29 +0000 (08:17 +0000)]
Test that %ENV iteration with prime_env_iter() is consistent

2 years agoTest SvIsBOOL() using XS::APItest
Paul "LeoNerd" Evans [Tue, 14 Sep 2021 20:59:22 +0000 (21:59 +0100)]
Test SvIsBOOL() using XS::APItest

Copy the Scalar::Util::isbool() tests into XS-APItest so we can avoid relying
on Scalar::Util just to check core functionality

2 years agomktables: Remove relics of removed legacy tables
Karl Williamson [Wed, 1 Sep 2021 12:10:49 +0000 (06:10 -0600)]
mktables: Remove relics of removed legacy tables

These mentions of the tables removed in
b852e1da77b497e086508451bebff00541073fb1 were missed in that commit.

2 years agot/re/fold_grind: Add a test case
Karl Williamson [Fri, 3 Sep 2021 12:33:28 +0000 (06:33 -0600)]
t/re/fold_grind: Add a test case

2 years agoSupport Unicode 14.0
Unicode Consortium [Wed, 15 Sep 2021 14:26:00 +0000 (08:26 -0600)]
Support Unicode 14.0

2 years agoregen/mk_invlists.pl: Add comment
Karl Williamson [Wed, 15 Sep 2021 14:25:27 +0000 (08:25 -0600)]
regen/mk_invlists.pl: Add comment

2 years agomktables: Split a Line Break equivalence class
Karl Williamson [Wed, 15 Sep 2021 13:36:41 +0000 (07:36 -0600)]
mktables: Split a Line Break equivalence class

This is used for the \b{lb}, and the rule is changing in Unicode 14.0

2 years agomktables: Reorder some comments, white-space
Karl Williamson [Wed, 15 Sep 2021 13:21:08 +0000 (07:21 -0600)]
mktables: Reorder some comments, white-space

Move comments closer to the action

2 years agomktables: Rename variable, and hoist calc from loop
Karl Williamson [Wed, 15 Sep 2021 13:08:05 +0000 (07:08 -0600)]
mktables: Rename variable, and hoist calc from loop

2 years agoSecond arg to force_list() is bool, so it should be written TRUE or FALSE
Paul "LeoNerd" Evans [Tue, 14 Sep 2021 23:16:54 +0000 (00:16 +0100)]
Second arg to force_list() is bool, so it should be written TRUE or FALSE

2 years agoFix OUTLIST handling for EU::ParseXS, and typemap fixes
Tony Cook [Mon, 13 Sep 2021 00:58:10 +0000 (10:58 +1000)]
Fix OUTLIST handling for EU::ParseXS, and typemap fixes

2 years agoParseXS: rename $c to $outlist_count
Tony Cook [Thu, 9 Sep 2021 01:04:05 +0000 (11:04 +1000)]
ParseXS: rename $c to $outlist_count

$c could be a count, but a count of what? clarify it.

2 years agotest and fix using T_CVREF_REFCOUNT as an output parameter
Tony Cook [Mon, 6 Sep 2021 05:33:19 +0000 (15:33 +1000)]
test and fix using T_CVREF_REFCOUNT as an output parameter

2 years agotest and fix using T_AVREF_REFCOUNT as an output parameter
Tony Cook [Mon, 6 Sep 2021 05:21:06 +0000 (15:21 +1000)]
test and fix using T_AVREF_REFCOUNT as an output parameter

2 years agotest and fix using T_HVREF_REFCOUNT as an output parameter
Tony Cook [Mon, 6 Sep 2021 05:09:49 +0000 (15:09 +1000)]
test and fix using T_HVREF_REFCOUNT as an output parameter

2 years agotest and fix using T_SVREF_REFCOUNT as an output parameter
Tony Cook [Mon, 6 Sep 2021 04:50:48 +0000 (14:50 +1000)]
test and fix using T_SVREF_REFCOUNT as an output parameter

2 years agobump $XS::Typemap::VERSION
Tony Cook [Mon, 6 Sep 2021 04:29:56 +0000 (14:29 +1000)]
bump $XS::Typemap::VERSION

2 years agotest and fix using T_SV as an OUTPUT parameter
Tony Cook [Mon, 6 Sep 2021 04:29:45 +0000 (14:29 +1000)]
test and fix using T_SV as an OUTPUT parameter

2 years agobump $ExtUtils::ParseXS::VERSION
Tony Cook [Mon, 6 Sep 2021 04:13:36 +0000 (14:13 +1000)]
bump $ExtUtils::ParseXS::VERSION

2 years agoParseXS: always XSprePUSH when producing an output list
Tony Cook [Mon, 6 Sep 2021 01:53:29 +0000 (11:53 +1000)]
ParseXS: always XSprePUSH when producing an output list

The late XSprePUSH with a non-PUSHx() RETVAL was causing the
stack and accesses to ST(n) to be out of sync.

If generated RETVAL code does write directly to ST(n) (as much does),
doesn't generate a push and we're generating output list code,
adjust SP to match to keep things in sync.

Also test that the original example case that worked, continues to
work.

Fixes #19054

2 years agoCheck for NULL locale in S_emulate_setlocale
Hugo van der Sanden [Sun, 12 Sep 2021 09:39:53 +0000 (10:39 +0100)]
Check for NULL locale in S_emulate_setlocale

gcc-11.2.0 correctly warns that it is called with NULL from
Perl_switch_to_global_locale().

2 years agoOn VMS, %ENV in scalar context must call prime_env_iter()
Nicholas Clark [Sun, 12 Sep 2021 10:42:25 +0000 (10:42 +0000)]
On VMS, %ENV in scalar context must call prime_env_iter()

Otherwise it will return wrong results, unless other code happens to
have iterated over %ENV. This bug has probably existed forever.

2 years agoSvIsBOOL's return type of 'bool' must be lowercase in =apidoc line
Paul "LeoNerd" Evans [Sat, 11 Sep 2021 21:40:37 +0000 (22:40 +0100)]
SvIsBOOL's return type of 'bool' must be lowercase in =apidoc line

2 years agoinstallhtml: set default podpath to './lib'
James E Keenan [Mon, 23 Aug 2021 16:35:51 +0000 (16:35 +0000)]
installhtml: set default podpath to './lib'

Previously (as reported nine years ago by Nick Clark in what is now
https://github.com/Perl/perl5/issues/11859), the default setting for
'podpath' was '.'.  This meant that, unless you explicitly set a
colon-delimited list of directories as the value for 'podpath', all
files containing POD under '.' were HTML-ified and installed.  The only
directories that always should have HTML-ized POD installed are 'lib'
and 'pod' itself.

Invoking 'installhtml' like the following should now DTRT:

        export HTMLDIR=$HOMEDIR/tmp/installhtml && \
        ./perl -Ilib ./installhtml    \
            --htmldir=$HTMLDIR     \
            --htmlroot=$HTMLDIR    \
            --splithead=pod/perlipc     \
            --recurse \
            --verbose 2>&1 | tee installhtml.log

2 years agoRun installhtml with $|
James E Keenan [Mon, 23 Aug 2021 15:26:36 +0000 (15:26 +0000)]
Run installhtml with $|

This will facilitate debugging of tickets like
https://github.com/Perl/perl5/issues/19052 and
https://github.com/Perl/perl5/issues/11859.

2 years agoFix a leak when copying a STATIC COW SV to a stringified SV
Nicholas Clark [Sat, 11 Sep 2021 10:11:21 +0000 (10:11 +0000)]
Fix a leak when copying a STATIC COW SV to a stringified SV

This is minor a a regression introduced by commit 914bb57489325d34:
    Define a third kind of COW state; STATIC

    ...

    sv_setsv_flags() and sv_setsv_cow() will preserve this state

There was a small omission in the copy code - it didn't handle the case where
the destination SV owned a string buffer already. This is actually
relatively rare - triggering it requires a scalar in code path that is
assigned both strings and booleans. Minimal test case is:

    my $got = 1;
    $got .= "";
    $got = ref "";

cut down from &is in t/comp/parser.t

2 years ago[MERGE] Stable tracking of "boolean intent" across SVs
Paul "LeoNerd" Evans [Fri, 10 Sep 2021 19:33:17 +0000 (20:33 +0100)]
[MERGE] Stable tracking of "boolean intent" across SVs

2 years agoAdd perldelta for stable bool
Paul "LeoNerd" Evans [Fri, 10 Sep 2021 17:48:48 +0000 (18:48 +0100)]
Add perldelta for stable bool

2 years agoAdd a Scalar::Util::isbool()
Paul "LeoNerd" Evans [Sat, 7 Aug 2021 14:11:40 +0000 (15:11 +0100)]
Add a Scalar::Util::isbool()

Remember to SvGETMAGIC() before testing SvIsBOOL() (thanks @tonycoz)

Unit-test that booleaness is preserved on values passed in to, out of, or captured by threads