This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
5 months agoIO: Update Changes
Tony Cook [Thu, 7 Dec 2023 23:02:16 +0000 (10:02 +1100)]
IO: Update Changes

5 months agodist/IO: move binmode from IO::File to IO::Handle
Tony Cook [Sun, 22 Oct 2023 23:39:54 +0000 (10:39 +1100)]
dist/IO: move binmode from IO::File to IO::Handle

since you can binmode() any handle.

Fixes #17457 which is most of this change, I only added tests, such
as they are.

5 months agoperldelta for 8acce4d007
Lukas Mai [Thu, 7 Dec 2023 17:59:50 +0000 (18:59 +0100)]
perldelta for 8acce4d007

5 months agoFcntl: export O_TMPFILE on request (Linux specific)
Lukas Mai [Wed, 6 Dec 2023 20:29:15 +0000 (21:29 +0100)]
Fcntl: export O_TMPFILE on request (Linux specific)

On Linux, several filesystems support the O_TMPFILE flag in open(2),
which allows creating an unlinked (unnamed) file. Check for the
O_TMPFILE flag and if present, export it from the Fcntl module on
request.

Fixes #21694.

5 months agoperldelta for 412d75ef55
Tony Cook [Thu, 7 Dec 2023 03:21:06 +0000 (14:21 +1100)]
perldelta for 412d75ef55

5 months agoskip porting/libperl.t on maint releases
Tony Cook [Thu, 30 Nov 2023 00:53:28 +0000 (11:53 +1100)]
skip porting/libperl.t on maint releases

maint-* branches, whether supported or not, may not be updated to
handle changes to nm's output due to updates to the operating system
or toolchain.

The same applies doubly to release tarballs.

So skip this test for maint/version numbers.

Keep the test for devel releases, since they have limited support
windows anyway, and we want this test to be done where possible.

Fixes #21677

5 months agoMention the version defer and try features were introduced in
E. Choroba [Wed, 27 Sep 2023 08:43:49 +0000 (10:43 +0200)]
Mention the version defer and try features were introduced in

All other features (including the experimental ones) mention it.

5 months ago[MERGE] make RC-stack-aware: pp_readline() etc
David Mitchell [Wed, 6 Dec 2023 16:53:44 +0000 (16:53 +0000)]
[MERGE] make RC-stack-aware: pp_readline() etc

Remove the temporary wrappers from:

    pp_readline()
    pp_rcatline()
    pp_glob()
    pp_rv2gv()
    pp_index()

and dependent functions.

This branch started out as an attempt to unwrap a few simple functions
like pp_index() and pp_rv2gv(). But pp_readline() calls pp_rv2gv(),
so that had to be unwrapped too. Then the bulk of pp_readline()'s
implementation is done by do_readline(), so that had to be updated too.
But pp_rcatline() and pp_glob() also call out to do_readline(), so they
had to be fixed too. And pp_glob() outsources most of its work to the
XS module File::Glob, so calling that had to be wrapped to handle a
non-refcounted stack in the XS code. Then it turns out that code in
IO.xs calls pp_readline() directly and needed tweaking.

So now its a larger branch that touches a lot of stuff.

5 months agoremove unused tryAMAGICunTARGETlist macro
David Mitchell [Tue, 5 Dec 2023 12:13:21 +0000 (12:13 +0000)]
remove unused tryAMAGICunTARGETlist macro

This macro was originally only used in two places in core (pp_readline
and pp_glob), and nowhere on CPAN.

The last few commits inlined those only two usages, then modified the
functions using that code to be PERL_RC_STACK-aware.

Since the macro is now unused, and is the old obsolete non-PERL_RC_STACK
code, this commit just deletes it.

5 months agomake RC-stack-aware: pp_readline(), pp_glob() etc
David Mitchell [Thu, 23 Nov 2023 18:21:38 +0000 (18:21 +0000)]
make RC-stack-aware: pp_readline(), pp_glob() etc

Remove the temporary wrappers from:

    pp_readline()
    pp_rcatline()
    pp_glob()
    pp_rv2gv()

and dependent functions.

This started out as an attempt to unwrap the simple pp_rv2gv() function.
But pp_readline() calls pp_rv2gv() too, so that had to be unwrapped too.
Then the bulk of pp_readline()'s implementation is done by
do_readline(), so that had to be updated too. But pp_rcatline() and
pp_glob() also call out to do_readline(), so they had to be fixed too.
And pp_glob() outsources most of its work to the XS module File::Glob,
so calling that had to be wrapped to handle a non-refcounted stack in
the XS code. Then it turns out that code in IO.xs calls pp_readline()
directly and needed tweaking.

So now its a large commit that updates nearly everything in one big go.

While fixing up everything, I took the opportunity to add many code
comments and asserts to better document what these various functions do,
and what args they expect on the stack under what flag conditions.

The op_flag processing is now more strict, so potentially other code
which directly fakes up an op with sloppy flag settings and calls one of
these pp functions directly might now trigger an assert failure. (See
the fix-up to IO.xs a couple of commits ago for an example.)

5 months agoexpand tryAMAGICunTARGETlist() macro
David Mitchell [Thu, 16 Nov 2023 18:25:50 +0000 (18:25 +0000)]
expand tryAMAGICunTARGETlist() macro

This long macro is only used in two places (pp_readline and pp_glob).
Expand the contents of this macro directly in those two functions.

This will make it easier to individually unwrap (i.e. remove
PP_wrapped()) those two functions.

Shouldn't be any functional change.

5 months agoIO::getline() handle OPf_STACKED better
David Mitchell [Sat, 25 Nov 2023 23:00:22 +0000 (23:00 +0000)]
IO::getline() handle OPf_STACKED better

When calling Perl_pp_readline(), only set OPf_STACKED, and only create a
dummy stacked target, when in scalar context. getline() had been sort of
getting away with always setting it, but the next commit but one will
make pp_readline() more strict about its flag handling (basically adding
lots of asserts and only processing the target when OPf_STACKED is set).

This change has been wrapped in a version #ifdef, as on older perls
pp_readline() will unconditionally try to retrieve the targ from the pad
if OPf_STACKED isn't set, and probably crash.

Note that until the next commit but one, this commit will probably fail
t/io_getline.t.

5 months agoIO::getline(): use CALLRUNOPS
David Mitchell [Sat, 25 Nov 2023 12:05:39 +0000 (12:05 +0000)]
IO::getline(): use CALLRUNOPS

This XS function calls Perl_pp_readline() directly. Instead, invoke the
op via CALLRUNOPS(): the run loop (that will just run a single op) can
handle the case of the caller having a non-reference-counted stack,
but when the ops it calls are expecting a reference-counted stack.

Perl_pp_readline() will (in a few commits' time) indeed be expecting a
reference-counted stack.

5 months agomake RC-stack-aware: unwrap pp_index()
David Mitchell [Thu, 16 Nov 2023 17:26:26 +0000 (17:26 +0000)]
make RC-stack-aware: unwrap pp_index()

Remove the temporary wrapper from pp_index()

5 months agoperldebug.pod: Fix broken link
Karl Williamson [Tue, 5 Dec 2023 21:12:00 +0000 (14:12 -0700)]
perldebug.pod: Fix broken link

79950615ae6d4a4ca72bf1b913b8e2842bd927e4 added what was marked as a
link, but should have been marked as C<>.

5 months agox-yuri is now a Perl author
Karl Williamson [Tue, 5 Dec 2023 21:11:35 +0000 (14:11 -0700)]
x-yuri is now a Perl author

5 months agoperldebug: clarify the readline support
x-yuri [Fri, 16 Sep 2022 16:36:01 +0000 (19:36 +0300)]
perldebug: clarify the readline support

5 months agoperldelta for fea90cfbe1f
Tony Cook [Mon, 4 Dec 2023 22:17:58 +0000 (09:17 +1100)]
perldelta for fea90cfbe1f

5 months agogrow the tmps (mortal) stack exponentially rather than linearly
Tony Cook [Thu, 23 Nov 2023 03:22:03 +0000 (14:22 +1100)]
grow the tmps (mortal) stack exponentially rather than linearly

As with the value stack and the save stack, this gives us constant
amortized growth per element.

After this patch the profiler shows the "SvPV_shrink_to_cur(sv)"
and "sv = sv_2mortal(newSV(80))" calls in do_readline as the
hotspots for the io unheated test case, using 55% of the measured
time in total.

Fixes #21654

5 months ago[MERGE] unwrap, optimise pp_aassign() and friends
David Mitchell [Mon, 4 Dec 2023 17:04:59 +0000 (17:04 +0000)]
[MERGE] unwrap, optimise pp_aassign() and friends

This branch:

- makes pp_aassign() RC-stack-aware

- optimises pp_aassign() on PERL_RC_STACK builds.

- also unwraps pp_emptyavhv() pp_refassign() and pp_undef(), chiefly to
  avoid skewing list assignment benchmark results.

- documents and adds tests for ref alias assignment in list context

- adds rpp_replace_at_norc() and several rpp_foo_NN() variants to the API

The main intent of this branch is to unwrap and optimise pp_aassign; all
the other commits came about as side-effects of that work.

The main optimisation work on pp_aassign() consists of: firstly,
skipping all the temps stack juggling that it used to do to avoid
prematurely freeing SVs, in such cases as @a = ($_a[0], ...). With an RC
stack this is no longer necessary. Secondly, trying to avoid
manipulating the stack as much as possible, now that every
rpp_replace_1_1() or similar requires two ref count adjustments, one of
which requires a conditional.

The Porting/bench.pl results on the expr::aassign:: subset of the
benchmarks gave an averages of around 96% on Ir, COND etc compared with
a non-PERL_RC_STACK blead build.

The work in this branch turned out to be a lot harder than I expected,
and took around two calendar months to get fully working.

5 months agofix Perl_rpp_is_lone() for immortals.
David Mitchell [Wed, 15 Nov 2023 16:57:06 +0000 (16:57 +0000)]
fix Perl_rpp_is_lone() for immortals.

Perl_rpp_is_lone() checks whether an SV is kept alive only by the args
and/or temps stack, and thus can in various circumstances be used
directly rather than copying - such as a return value from a function, or
assigning a value to an array or hash.

However, this assumption fails on immortal SVs like PL_sv_undef. Their
refcount can reach 1 but they should still be copied rather than stolen.

This showed itself as an extremely intermittent failure in

    cpan/Test-Harness/t/compat/test-harness-compat.t

It only showed up when both these conditions were met:

- on DEBUGGING builds, because that sets the initial ref count of the
immortals to 1000 rather than I32_MAX, making such problems easier to
reproduce; *and*

- under PERL_RC_STACK, because only on that build do you have SVs
on the args stack (but not temps stack) with RC==1 which are stealable.
Also under the RC build, as an optimisation, &PL_sv_undef is often
pushed on the stack without incrementing its RC. Thus it is more liklely
to reach RC==1.

I don't know why the failure on that test was intermittent, even after
setting PERL_HASH_SEED=0. Perhaps it was timing related. Certainly
anything which made it slower, such as strace, valgrind or ASAN, made
the problem go away or fail only after days rather than minutes.

This commit also decreases the value of SvREFCNT_IMMORTAL on
debugging builds from 1000 to 10 under PERL_RC_STACK, to make such
issues/bugs more likely to be triggered.

5 months agopp_aassign: move UID/GID code into separate fn
David Mitchell [Sun, 5 Nov 2023 19:05:01 +0000 (19:05 +0000)]
pp_aassign: move UID/GID code into separate fn

There is a big chunk of code near the end of pp_aassign() which is
responsible for updating the OS's UIDs and/or GIDs after something like

    ($<,$>) = ($>,$<);

has been executed. This code is long and has little to with list
assignment generally, so move it out into a separate static function.

This commit makes no changes to that chunk of code apart from
indentation (hopefully).

5 months agopp_aassign: optimise: just zero hash stack elems
David Mitchell [Sun, 5 Nov 2023 16:00:44 +0000 (16:00 +0000)]
pp_aassign: optimise: just zero hash stack elems

Similar to the previous commit but for hashes rather than arrays,
in PERL_RC_STACK builds, When passing ownership of a bunch of SVs on the
stack to a hash they've just been stored in, just zero out that
section of the stack and shift first_discard downwards, rather than
storing &PL_sv_undef in all the stack slots. This means that at the end,
PL_stack_sp can be reset directly to the base of those elements rather
than decrementing the ref count of &PL_sv_undef N times.

5 months agopp_aassign: optimise: just zero array stack elems
David Mitchell [Sun, 5 Nov 2023 15:24:20 +0000 (15:24 +0000)]
pp_aassign: optimise: just zero array stack elems

In PERL_RC_STACK builds, When passing ownership of a bunch of SVs on the
stack to an array they've just been stored in, just zero out that
section of the stack and shift first_discard downwards, rather than
storing &PL_sv_undef in all the stack slots. This means that at the end,
PL_stack_sp can be reset directly to the base of those elements rather
than decrementing the ref count of &PL_sv_undef N times.

5 months agopp_aassign: optimise: lelem++ at end of loop
David Mitchell [Sat, 4 Nov 2023 16:31:32 +0000 (16:31 +0000)]
pp_aassign: optimise: lelem++ at end of loop

There are a couple of loops along the lines of

    while (...) {
        SV *lsv = *lelem++;
        ....
        do stuff with lelem[-1]
    }

change them to

    while (...) {
        SV *lsv = *lelem;
        ....
        do stuff with *lelem
        lelem++
    }

5 months agopp_aassign: optimise: store NULLs in L elem slots
David Mitchell [Thu, 2 Nov 2023 15:17:09 +0000 (15:17 +0000)]
pp_aassign: optimise: store NULLs in L elem slots

(This commit only affects code within PERL_RC_STACK ifdefs)

In a list assignment such as (L1, L2, ...) = (R1, R2, ...),
pp_assign is called with the stack looking like:

    * R1 R2 ... * L1 L2 ...

Previously, all elements on the stack were popped at the end. This
commit changes it so that after each L element is processed, it is freed
and a NULL (or sometimes &PL_sv_undef) is stored at that slot in the
stack. Then at the end, PL_stack_sp can just be set to one slot below the
ex-L1, without having to run a loop  popping each element off the stack.
This reduces the number of memory reads and branches, at the cost of
more writes.

(All the R elems will still need to be freed, though).

5 months agopp_aassign: skip copying scalars back to stack
David Mitchell [Thu, 28 Sep 2023 17:45:51 +0000 (18:45 +0100)]
pp_aassign: skip copying scalars back to stack

Consider a list assignment where there are scalars on the LHS, such
as:

    ($x,$y,$z) = ($a,$b,$c);

Except in the rare cases where the list assignment is itself in list
context, such as

    @a = ( ($x,$y,$z) = ($a,$b,$c) )

then there is no need to copy $x to the $a stack position, $y to $b and
$z to $c in order to return ($x,$y,$z). Instead leave the stack as-is,
containing ($a,$b,$c,$x,$y,$z), with all six SV pointers on the stack
untouched. When pp_assign() is about to return, it will just pop the 6
elements off the stack.

Less messing with the stack becomes more important on PERL_RC_STACK
builds, because needlessly putting things on and off the stack requires
more ref count manipulation and testing.

5 months agopp_aassign: add is_list local variable
David Mitchell [Thu, 28 Sep 2023 17:38:17 +0000 (18:38 +0100)]
pp_aassign: add is_list local variable

It may be slightly more efficient than testing for (gimme == G_LIST)
in hot loops.

5 months agouse rpp_foo_NN() variants in pp_aassign, pp_rv2av
David Mitchell [Tue, 26 Sep 2023 20:09:19 +0000 (21:09 +0100)]
use rpp_foo_NN() variants in pp_aassign, pp_rv2av

These make the code slightly faster. This commit is kind of a proof of
concept: only pp_aassign (and the related op pp_rv2av) have been updated
to use these new variants for now. Making the rest of code use them will
be done later.

5 months agoAdd some _NN variants of rpp_() functions.
David Mitchell [Tue, 26 Sep 2023 19:54:22 +0000 (20:54 +0100)]
Add some _NN variants of rpp_() functions.

Namely:

    rpp_popfree_1_NN()
    rpp_popfree_2_NN()
    rpp_popfree_to_NN(svp)

    rpp_replace_1_1_NN(sv)
    rpp_replace_2_1_NN(sv)
    rpp_replace_at_NN(sp, sv)
    rpp_replace_at_norc_NN(sp, sv)

These are more efficient, as they can skip checking that the existing
pointers on the stack are non-NULL before attempting to decrement their
reference count.

Note that the *args* of the original (non-variant) functions (as opposed
the values on the stack) were already assumed to be non-NULL.

5 months agouse rpp_replace_at_norc in refassign, aassign
David Mitchell [Sun, 5 Nov 2023 17:58:36 +0000 (17:58 +0000)]
use rpp_replace_at_norc in refassign, aassign

Use the just-added function rpp_replace_at_norc() to simplify some blocks
of code recently added to pp_refassign() and pp_aassign()

5 months agoadd rpp_replace_at_norc() to API
David Mitchell [Sun, 5 Nov 2023 17:57:20 +0000 (17:57 +0000)]
add rpp_replace_at_norc() to API

It's like rpp_replace_at(), but it assumes that the SV has already had
its refcount bumped. It replaces ugly code like

        SV *nsv = newSVsv(*svp);
    #ifdef PERL_RC_STACK
        rpp_replace(svp, nsv);
        SvREFCNT_dec(nsv);
    #else
        rpp_replace(svp, sv_2mortal(nsv));
    #endif

with a simple

    rpp_replace_at_norc(svp, newSvsv(*svp));

On PERL_RC_STACK builds it's more efficient than before as it's not
unnecessarily bumping and then immediately unbumping nsv's refcount.

5 months agopp_aassign: fix "RC==1" optimisation checks
David Mitchell [Mon, 25 Sep 2023 21:18:19 +0000 (22:18 +0100)]
pp_aassign: fix "RC==1" optimisation checks

The code sometimes skips a copying step if the ref count of the SV
is 1. Under PERL_RC_STACK, the ref count can now be 2, with the
optimisation still being valid.

5 months agopp_aassign: remove panic check under PERL_RC_STACK
David Mitchell [Sun, 24 Sep 2023 20:21:06 +0000 (21:21 +0100)]
pp_aassign: remove panic check under PERL_RC_STACK

There is some code in S_aassign_copy_common() (helper function for
pp_aassign()) which checks for SvIS_FREED() of the current arg.
The comments imply that the check is there specifically to help a TODO
test in t/op/sort.t not randomly crash. That test does stuff which
triggers a premature free of args on the stack.

This test was later disabled entirely, as whatever panics or crashes
were being triggered weren't being caught by the eval {} it was wrapped
in.

This commit, only on PERL_RC_STACK builds, skips the SvIS_FREED check,
and re-enables the test in sort.t (as a real test, not a TODO).

5 months agopp_aassign: optimise SV branch under PERL_RC_STACK
David Mitchell [Sun, 24 Sep 2023 19:38:18 +0000 (20:38 +0100)]
pp_aassign: optimise SV branch under PERL_RC_STACK

The block of code that handles

    ($scalar, ...) = (...);

used to handle things specially if $scalar was currently a ref, in case
assigning to $scalar freed the referent which was later used on the RHS.
With a ref-counted stack that is no longer a problem.

All changes are wrapped in '#ifdef PERL_RC_STACK' etc.

5 months agopp_aassign: optimise HV branch under PERL_RC_STACK
David Mitchell [Sun, 24 Sep 2023 14:44:35 +0000 (15:44 +0100)]
pp_aassign: optimise HV branch under PERL_RC_STACK

The block of code that handles

    (..., %a) = (...);

used to temporarily store on the temps stack, pointers to all the RH
value elements (and sometimes the keys too), in order to avoid things
being prematurely freed, such as in %h = ($h{a}, ...). Under
PERL_RC_STACK builds this is no longer necessary, so simplify the code.

All changes are wrapped in '#ifdef PERL_RC_STACK' etc.

5 months agopp_aassign: optimise AV branch under PERL_RC_STACK
David Mitchell [Sun, 24 Sep 2023 14:23:07 +0000 (15:23 +0100)]
pp_aassign: optimise AV branch under PERL_RC_STACK

The block of code that handles

    (..., @a) = (...);

used to temporarily store on the temps stack, pointers to all the RH
elements, in order to avoid things being prematurely freed, such as in
@a = ($a[0], ...). Under PERL_RC_STACK builds this is no longer
necessary, so simplify the code.

All changes are wrapped in '#ifdef PERL_RC_STACK' etc.

Aliasing needs special handling. When in list context, we return refs
to SVs, but store the SVs themselves in the AV. In the traditional
approach, the stack keeps the RVs while the temps stack has the SvRV()
values - this makes it easy to block copy the SVs to the array while
leaving the stack untouched. When the temps stack is no longer being
used, we have to manually dereference each RV as we assign values to the
stack. Do this using the slow av_store() loop rather than the optimised
Copy(AvARRAY(),...) branch.

5 months agomake RC-stack-aware: unwrap pp_aassign()
David Mitchell [Mon, 11 Sep 2023 14:11:42 +0000 (15:11 +0100)]
make RC-stack-aware: unwrap pp_aassign()

Remove the temporary wrapper from pp_aassign()

Note that this is a very basic unwrapping: in particular, pp_aassign()
still heavily uses the temps stack, but now mostly unnecessarily. The
next few commits will start optimising things.

5 months agomake RC-stack-aware: unwrap pp_undef()
David Mitchell [Mon, 25 Sep 2023 08:36:12 +0000 (09:36 +0100)]
make RC-stack-aware: unwrap pp_undef()

Remove the temporary wrapper from pp_undef()

5 months agomake RC-stack-aware: unwrap pp_refassign()
David Mitchell [Sun, 24 Sep 2023 21:11:21 +0000 (22:11 +0100)]
make RC-stack-aware: unwrap pp_refassign()

Remove the temporary wrapper from pp_refassign()

Also move a couple of variable declarations into the smallest scope
possible: mg and stash are used only by (and implicitly by)
SvCANEXISTDELETE().

5 months agoop/array.t: skip \$#{[]} test under PERL_RC_STACK
David Mitchell [Thu, 16 Nov 2023 13:10:30 +0000 (13:10 +0000)]
op/array.t: skip \$#{[]} test under PERL_RC_STACK

PERL_RC_STACK builds fixes a bug whereby the [] was being prematurely
freed. So the test, which was testing that perl didn't crash when
trying to set the length of a freed array, was now trying to set the
size of the array to some large number, and was failing under ASAN.

5 months agomake RC-stack-aware: unwrap pp_emptyavhv()
David Mitchell [Sun, 5 Nov 2023 19:30:09 +0000 (19:30 +0000)]
make RC-stack-aware: unwrap pp_emptyavhv()

Remove the temporary wrapper from pp_emptyavhv()

Also fix some tests in array.t, which were expecting a temp empty array
ref to be prematurely freed. With PERL_RC_STACK, it's no longer
prematurely freed.

5 months agoHash-Util-FieldHash: fixup test on PERL_RC_STACK
David Mitchell [Thu, 9 Nov 2023 12:41:20 +0000 (12:41 +0000)]
Hash-Util-FieldHash: fixup test on PERL_RC_STACK

Hash::Util::FieldHash is an implementation of "inside out" objects,
where field values are stored in per-field hashes whose keys are the
numeric addresses of the objects, and whose values represent the value
of that field for a particular object.

The hashes are magic, in that they don't hold a reference to each
object, but automatically delete the relevant entry from the hash when
the object is freed. This is achieved internally with weak references
and a bunch of user magic attached to the hash and the object.

A test in 02_function.t checks that such a link in the magic hash to an
object is removed after the real object is freed. This test looked
something like:

    $h{[]} = 123;
    is(keys %h, 0);

which relied on the temp anon array being freed almost immediately and
triggering the hash delete. Now it turns out that OP_ANONLIST (and its
later optimisation, OP_EMPTYAVHV) return an SvTEMP RV. In the code
above, this means that [] gets freed at the start of the next statement
(by the freetmps() in pp_nextstate()), and all works as expected.

However, when pp_emptyavhv() is unwrapped in the next commit, on
PERL_RC_STACK builds it will skip mortalising the return result, and
just rely on the ref count from the stack to keep the RV alive as long
as needed. By "needed", this is only while the helem op is being
executed, and the temp array is thus freed at the end of the helem,
rather than at the end of the statement. This triggers the entry in the
hash being auto-deleted earlier, so when the next op, the scalar assign,
executes, it triggers a warning:

    Useless assignment to a temporary at t/02_function.t line 121.

After a lot of faffing about trying to work out what was going on, I
concluded that the intent of the test could just as well be done by
creating a real array reference variable and to just undef it directly
after the hash assign.

(I.e. it took some time to convince myself that there wasn't a bug in
pp_emptyavhv, pp_sassign nor FieldHash.xs, and that just the test needed
fixing.)

5 months agoadd lvalue scalar alias tests to lvref.t
David Mitchell [Sun, 5 Nov 2023 18:43:45 +0000 (18:43 +0000)]
add lvalue scalar alias tests to lvref.t

This is a compile-time error:

   (\$x = \1) = \2;

However, the following is legal code, but is untested (the 'OPf_MOD'
branch in pp_refassign() is not triggered by the test suite):

   f(\$x = \1);

So this commit adds some tests. It assumes that the above code is
equivalent to:

   \$x = \1;
   f(\$x);

Whether the existing behaviour is sane is up for debate, but if
if we change it, it should be a deliberate choice, not an accidental
change not spotted by the existing tests.

5 months agoadd list context tests to t/op/lvref.t
David Mitchell [Thu, 19 Oct 2023 09:09:27 +0000 (10:09 +0100)]
add list context tests to t/op/lvref.t

Codify the existing behaviour of alias list assignment in list
context, e.g.

    .... = (  (\$x, \$y, \(@a)) = (....)  );
and
           (  (\$x, \$y, \(@a)) = (....)  ) = ....;

Whether the existing behaviour is sane is up for debate, but if
if we change it, it should be a deliberate choice, not an accidental
change not spotted by the existing tests.

5 months agodocument ref assignment in list context
David Mitchell [Fri, 10 Nov 2023 12:22:12 +0000 (12:22 +0000)]
document ref assignment in list context

The 'refaliasing' feature, whereby assigning to a literal reference
causes an aliasing operation (e.g. \$x = \...) didn't document what was
returned if the assignment was done in list context.

This commit adds a basic summary to the docs.

See the thread http://nntp.perl.org/group/perl.perl5.porters/267074
for the discussion.

5 months agocpan/Test-Simple - Update to version 1.302198
Chad Granum [Fri, 1 Dec 2023 12:02:22 +0000 (07:02 -0500)]
cpan/Test-Simple - Update to version 1.302198

1.302198  2023-11-30 10:07:14-08:00 America/Los_Angeles

    - Remove use of defined-or operator

6 months agoCapture perl5343delta, perl5363delta, perl5382delta
Paul "LeoNerd" Evans [Thu, 30 Nov 2023 15:53:26 +0000 (15:53 +0000)]
Capture perl5343delta, perl5363delta, perl5382delta

6 months agoAdd Perl versions 5.34.3, 5.36.3, 5.38.2 to perlhist.pod
Paul "LeoNerd" Evans [Thu, 30 Nov 2023 15:35:26 +0000 (15:35 +0000)]
Add Perl versions 5.34.3, 5.36.3, 5.38.2 to perlhist.pod

6 months agobisect: explicitly set diff path prefixes
Lukas Mai [Thu, 23 Nov 2023 06:04:57 +0000 (07:04 +0100)]
bisect: explicitly set diff path prefixes

The patch code in Porting/bisect-runner.pl assumes `git show` will
always display filenames with "a/..." and "b/..." prefixes. This is not
necessarily the case. For example, the config settings
diff.mnemonicPrefix and diff.noprefix can cause different prefixes or no
prefixes at all to be used. In that case (e.g. after `git config
--global diff.noprefix true`), bisect will halt like this:

    HEAD is now at 95388f2eb2 perlhist: Move 5.26.0 to another table to fix line length
    can't find file to patch at input line 24
    Perhaps you used the wrong -p or --strip option?
    The text leading up to this was:
    --------------------------
    |commit 46bfb3c49f22629a21d99ff2d02461a2a8a9aac4
    |Author: Nicholas Clark <nick@ccl4.org>
    |Date:   2022-08-02 16:40:39 +0200
    |
    |    Configure should avoid looping infinitely repeating the same question
    |
    |    Configure's helper function ./myread is intended to loop until it gets an
    |    acceptable answer. For a couple of cases, an empty string is not acceptable
    |    (eg 'Where is your C library?', if all automated attempts at answering this
    |    have failed). In these cases, if Configure's standard input is /dev/null (or
    |    closed), the shell read returns an empty string, and ./myread repeats the
    |    question.
    |
    |    Before this commit, it would loop infinitely (generating continuous terminal
    |    output). With this commit, we add a retry counter - if it asks the same
    |    question to many times, it aborts Configure. This means that unattended
    |    ./Configure runs should now always terminate, as termination with an error
    |    is better than spinning forever.
    |
    |diff --git Configure Configure
    |index 9d7fc39419..9d3b5f73b1 100755
    |--- Configure
    |+++ Configure
    --------------------------
    File to patch:

... which seems silly, seeing as how the filename is right there ("diff
--git Configure Configure", "--- Configure", "+++ Configue") and yet
bisect has to ask which file to patch ("it's Configure, duh!").

This commit tells git explicitly to use "a/" and "b/" as prefixes, which
works no matter what the local config settings are.

6 months agoModule::CoreList updated for v5.34.3, v5.36.3 and v5.38.2
Chris 'BinGOs' Williams [Wed, 29 Nov 2023 21:32:30 +0000 (21:32 +0000)]
Module::CoreList updated for v5.34.3, v5.36.3 and v5.38.2

6 months agocpan/Test-Simple - Update to version 1.302197
Chad Granum [Wed, 29 Nov 2023 16:42:19 +0000 (11:42 -0500)]
cpan/Test-Simple - Update to version 1.302197

1.302197  2023-11-28 17:30:37-08:00 America/Los_Angeles

    - Add ability to attach timestamps to trace objects via api or env var

1.302196  2023-10-24 10:27:33-07:00 America/Los_Angeles

    - Fix #882
    - Fix handling of VSTRING and LVALUE refs in is_deeply() #918
    - Merge several doc fixes from mauke

6 months agoElephants never forget
Chris 'BinGOs' Williams [Wed, 29 Nov 2023 16:50:24 +0000 (16:50 +0000)]
Elephants never forget

6 months agoperlport: -l is now meaningful on Win32
Tony Cook [Thu, 26 Oct 2023 01:50:43 +0000 (12:50 +1100)]
perlport: -l is now meaningful on Win32

6 months agoperlport: windows strange behaviour with . at the end of names
Tony Cook [Thu, 26 Oct 2023 01:32:08 +0000 (12:32 +1100)]
perlport: windows strange behaviour with . at the end of names

Fixes #14687

6 months agoperlport: -S on Win32 has been meaningful since 01052a1d7
Tony Cook [Thu, 26 Oct 2023 00:02:17 +0000 (11:02 +1100)]
perlport: -S on Win32 has been meaningful since 01052a1d7

6 months agoperldeprecation: fix typo and formatting in dot in inc entry
Dagfinn Ilmari Mannsåker [Tue, 28 Nov 2023 16:38:35 +0000 (16:38 +0000)]
perldeprecation: fix typo and formatting in dot in inc entry

6 months agoRemember to add recently-captured perldelta files to MANIFEST and win32/pod.mak
Paul "LeoNerd" Evans [Tue, 28 Nov 2023 16:35:37 +0000 (16:35 +0000)]
Remember to add recently-captured perldelta files to MANIFEST and win32/pod.mak

6 months agoGNUmakefile: copy libmcfgthread-1.dll to 't' directory
sisyphus [Fri, 24 Nov 2023 00:08:10 +0000 (11:08 +1100)]
GNUmakefile: copy libmcfgthread-1.dll to 't' directory

Avoids test failures when gcc is configured to use MCF threads.
See Issue #21038

6 months agoCapture perl5342delta, perl5362delta, perl5381delta
Paul "LeoNerd" Evans [Tue, 28 Nov 2023 12:03:37 +0000 (12:03 +0000)]
Capture perl5342delta, perl5362delta, perl5381delta

6 months agolocale.c: Change type of a variable to silence compiler warning
TAKAI Kousuke [Tue, 21 Nov 2023 17:26:32 +0000 (02:26 +0900)]
locale.c: Change type of a variable to silence compiler warning

The variable `already_checked` in Perl_init_i18nl10n() never become
negative, and never exceed `C_trial` which is a small positive integer.
Thus `unsigned int` should be enough.

This fixes build warning on 32-bit target
(where sizeof(unsigned int) == sizeof(SSize_t)):
    locale.c: In function ‘Perl_init_i18nl10n’:
    locale.c:7370:40: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘ssize_t’ {aka ‘int’} [-Wsign-compare]
     7370 |             for (unsigned int i = 0; i < already_checked; i++) {
          |                                        ^

6 months agodefine HAS_TRUNC and $Config{d_trunc)for MSVC builds
sisyphus [Sat, 25 Nov 2023 00:34:55 +0000 (11:34 +1100)]
define HAS_TRUNC and $Config{d_trunc)for MSVC builds

Fixes POSIX/t/math.t failures on MSVC builds of MSWin32-x86-multi-thread

6 months agore: fix wording in documentation
Lukas Mai [Mon, 27 Nov 2023 09:25:23 +0000 (10:25 +0100)]
re: fix wording in documentation

Fixes #21674.

6 months ago`valgrindpp.pl`: Fix `new` indirect syntax
Elvin Aslanov [Sun, 12 Nov 2023 11:04:53 +0000 (12:04 +0100)]
`valgrindpp.pl`: Fix `new` indirect syntax

In two places
Also format POD in few places

6 months agopp.c: Add dummy goto to silence -Wunused-label warning in pp_divide
TAKAI Kousuke [Wed, 15 Nov 2023 17:23:52 +0000 (02:23 +0900)]
pp.c: Add dummy goto to silence -Wunused-label warning in pp_divide

The label "ret" was only referred in PERL_TRY_UV_DIVIDE block
which is not compiled on typical 32-bit build, thus it used to
trigger a warning like "label ‘ret’ defined but not used".

Added goto will be optimized out and should not incur any runtime
overhead.

6 months agodon't optimize (or warn about) control flow ops in OP_SASSIGN
Lukas Mai [Fri, 24 Nov 2023 03:30:50 +0000 (04:30 +0100)]
don't optimize (or warn about) control flow ops in OP_SASSIGN

In short, '$a = return $b' is stored "backwards": OP_SASSIGN has the RHS
of the assignment as its first operand. Warning about precedence makes
no sense here.

Logical assignment ops like //=, ||=, &&= are represented as
OP_{DOR,OR,AND}ASSIGN wrapped around a weird single-child OP_SASSIGN.
Trying to naively elide the inner OP_SASSIGN leaves a dangling outer
OP_{DOR,OR,AND}ASSIGN (which B::Deparse doesn't know what to do with) or
just makes the compiler loop indefinitely. So just don't.

Fixes #21665.

6 months agoMore Module::CoreList hackery; as it should claim that the new perl releases should...
Paul "LeoNerd" Evans [Sun, 26 Nov 2023 14:14:32 +0000 (14:14 +0000)]
More Module::CoreList hackery; as it should claim that the new perl releases should contain that new version of Module::CoreList + M:CL:Utils itself

6 months agoAdd perldelta for recent security fixes
Paul "LeoNerd" Evans [Sun, 26 Nov 2023 13:40:39 +0000 (13:40 +0000)]
Add perldelta for recent security fixes

6 months agowin32: default the shell to cmd.exe in the Windows system directory
Tony Cook [Mon, 2 Oct 2023 22:40:07 +0000 (09:40 +1100)]
win32: default the shell to cmd.exe in the Windows system directory

This prevents picking up cmd.exe from the current directory, or
even from the PATH.

This protects against a privilege escalation attack where an attacker
in a separate session creates a cmd.exe in a directory where the
target account happens to have its current directory.

6 months agoFix read/write past buffer end: perl-security#140
Karl Williamson [Sat, 9 Sep 2023 17:59:09 +0000 (11:59 -0600)]
Fix read/write past buffer end: perl-security#140

A package name may be specified in a \p{...} regular expression
construct.  If unspecified, "utf8::" is assumed, which is the package
all official Unicode properties are in.  By specifying a different
package, one can create a user-defined property with the same
unqualified name as a Unicode one.  Such a property is defined by a sub
whose name begins with "Is" or "In", and if the sub wishes to refer to
an official Unicode property, it must explicitly specify the "utf8::".
S_parse_uniprop_string() is used to parse the interior of both \p{} and
the user-defined sub lines.

In S_parse_uniprop_string(), it parses the input "name" parameter,
creating a modified copy, "lookup_name", malloc'ed with the same size as
"name".  The modifications are essentially to create a canonicalized
version of the input, with such things as extraneous white-space
stripped off.  I found it convenient to strip off the package specifier
"utf8::".  To to so, the code simply pretends "lookup_name" begins just
after the "utf8::", and adjusts various other values to compensate.
However, it missed the adjustment of one required one.

This is only a problem when the property name begins with "perl" and
isn't "perlspace" nor "perlword".  All such ones are undocumented
internal properties.

What happens in this case is that the input is reparsed with slightly
different rules in effect as to what is legal versus illegal.  The
problem is that "lookup_name" no longer is pointing to its initial
value, but "name" is.  Thus the space allocated for filling "lookup_name"
is now shorter than "name", and as this shortened "lookup_name" is
filled by copying suitable portions of "name", the write can be to
unallocated space.

The solution is to skip the "utf8::" when reparsing "name".  Then both
"lookup_name" and "name" are effectively shortened by the same amount,
and there is no going off the end.

This commit also does white-space adjustment so that things align
vertically for readability.

This can be easily backported to earlier Perl releases.

6 months agoAdd maint releases of 5.34.2, 5.36.2, 5.38.1 to perlhist.pod
Paul "LeoNerd" Evans [Tue, 21 Nov 2023 16:22:12 +0000 (16:22 +0000)]
Add maint releases of 5.34.2, 5.36.2, 5.38.1 to perlhist.pod

6 months agoUpdate Module::CoreList for upcoming releases of 5.34.2, 5.36.2, 5.38.1
Paul "LeoNerd" Evans [Tue, 21 Nov 2023 15:24:43 +0000 (15:24 +0000)]
Update Module::CoreList for upcoming releases of 5.34.2, 5.36.2, 5.38.1

6 months agocpan/Math-BigInt - Update to version 2.001001
Peter John Acklam [Sat, 25 Nov 2023 01:24:28 +0000 (20:24 -0500)]
cpan/Math-BigInt - Update to version 2.001001

2.001001 2023-11-21

 * Fix CPAN RT #150469

6 months agobump IO::* version to 1.55
Lukas Mai [Fri, 24 Nov 2023 20:00:14 +0000 (21:00 +0100)]
bump IO::* version to 1.55

6 months ago[doc] `Select.pm`: Scope Examples
Elvin Aslanov [Fri, 10 Nov 2023 23:59:53 +0000 (00:59 +0100)]
[doc] `Select.pm`: Scope Examples

By adding `my` where appropriate

6 months ago`Deparse.t`: Fix `new` indirect syntax
Elvin Aslanov [Sat, 11 Nov 2023 17:28:08 +0000 (18:28 +0100)]
`Deparse.t`: Fix `new` indirect syntax

In two places

6 months agosv_isa_sv() no longer considered experimental
Paul "LeoNerd" Evans [Wed, 22 Nov 2023 18:08:16 +0000 (18:08 +0000)]
sv_isa_sv() no longer considered experimental

6 months agoelide right operand if left operand transfers control
Lukas Mai [Sun, 19 Nov 2023 17:37:39 +0000 (18:37 +0100)]
elide right operand if left operand transfers control

This commit contains the following changes:

- The "possible precedence issue" warning now mentions (in parentheses)
  the name of the control flow operator that triggered the warning:

      $ ./perl -cwe 'return $a or $b'
      Possible precedence issue with control flow operator (return) at -e line 1.

- CORE::dump now counts as a control flow operator:

      $ ./perl -cwe 'CORE::dump or f()'
      Possible precedence issue with control flow operator (dump) at -e line 1.

- Any binary operator whose left operand is a control flow operator is
  optimized out along with any right operand it may have, even if no
  warning is triggered:

      $ ./perl -Ilib -MO=Deparse -we '(die $a) + $b'
      BEGIN { $^W = 1; }
      die $a;
      -e syntax OK

  (No warnings because explicit parentheses are used in the preceding
  example.)

      $ ./perl -Ilib -MO=Deparse -we 'exit $a ? 0 : 1'
      Possible precedence issue with control flow operator (exit) at -e line 1.
      BEGIN { $^W = 1; }
      exit $a;
      -e syntax OK

6 months agolocale.c: Fix typo in comment
Karl Williamson [Wed, 22 Nov 2023 19:10:36 +0000 (12:10 -0700)]
locale.c: Fix typo in comment

6 months agoharness: fix operator precedence in call to exit
Lukas Mai [Wed, 22 Nov 2023 05:14:31 +0000 (06:14 +0100)]
harness: fix operator precedence in call to exit

Previously:

    $ ./perl -w -c t/harness
    Possible precedence issue with control flow operator at t/harness line 498.
    t/harness syntax OK

6 months agoperlapi: Note that StructCopy is a shallow copy;
Karl Williamson [Tue, 21 Nov 2023 13:46:30 +0000 (06:46 -0700)]
perlapi: Note that StructCopy is a shallow copy;

This is essential information that should be revealed up front.

6 months agoIdentify default mingw runtime (mingw builds only).
sisyphus [Mon, 20 Nov 2023 03:49:59 +0000 (14:49 +1100)]
Identify default mingw runtime (mingw builds only).

See https://github.com/Perl/perl5/pull/21612 for context.

Basically, by setting $Config{libc} to the default runtime (which will
be either -lucrt or -lmsvcrt) we enable perl scripts to determine the
identity of the default runtime.

6 months agoRevert "Also adjust t/xsub_h.t to use $^V." part of 4a88c3486c for maint
Steve Hay [Mon, 10 Apr 2023 17:10:45 +0000 (18:10 +0100)]
Revert "Also adjust t/xsub_h.t to use $^V." part of 4a88c3486c for maint

The error produced in this test, running against perl 5.36.1, is:

Perl API version v1.0.16 of Pie does not match v5.36.0

which doesn't match the expected error when $^V is used because that is
5.36.1.

It's the API version that we're expecting in the output, and that's frozen
at .0 for maint releases (unlike blead, where it incremented for every
release).

6 months agoextend "Possible precedence issue" warning, cover more cases
Lukas Mai [Sun, 19 Nov 2023 09:47:03 +0000 (10:47 +0100)]
extend "Possible precedence issue" warning, cover more cases

Previously, code like

    return $a or $b;

would emit a warning of the form "Possible precedence issue with control
flow operator" because it parses as (return $a) or $b.

However, the equally misleading

    exit $a != 0;      # exit($a) != 0
    exit $a ? 0 : $b;  # exit($a) ? 0 : $b

were not diagnosed.

This patch moves the check higher up in the compiler: Now any binary or
ternary operator (not just logical operators) warns if its first operand
is an unparenthesized control flow operator that does not terminate
normally (i.e. next, last, redo, goto, exit, return, die).

6 months agoembed.fnc: we require C99 variadic macros now
Lukas Mai [Sun, 19 Nov 2023 08:54:23 +0000 (09:54 +0100)]
embed.fnc: we require C99 variadic macros now

As pod/perlhacktips.pod states, we require C compilers to support C99
variadic macros now (since 5.35.5). So remove the comment saying
otherwise from embed.fnc.

6 months agoNeater lists of header/source/object files in Makefile.SH
Paul "LeoNerd" Evans [Thu, 16 Nov 2023 13:35:14 +0000 (13:35 +0000)]
Neater lists of header/source/object files in Makefile.SH

6 months agorecord Module::CoreList release in praesumptio
Karen Etheridge [Mon, 20 Nov 2023 04:00:57 +0000 (20:00 -0800)]
record Module::CoreList release in praesumptio

6 months agoUpdate Module::CoreList for 5.39.6
Karen Etheridge [Mon, 20 Nov 2023 03:49:17 +0000 (19:49 -0800)]
Update Module::CoreList for 5.39.6

6 months agoBump the perl version in various places for 5.39.6
Karen Etheridge [Mon, 20 Nov 2023 03:35:08 +0000 (19:35 -0800)]
Bump the perl version in various places for 5.39.6

6 months agoNew perldelta for 5.39.5
Karen Etheridge [Mon, 20 Nov 2023 03:24:53 +0000 (19:24 -0800)]
New perldelta for 5.39.5

6 months agofix version here too
Karen Etheridge [Mon, 20 Nov 2023 03:18:11 +0000 (19:18 -0800)]
fix version here too

6 months agofix release year for 5.40
Karen Etheridge [Mon, 20 Nov 2023 03:16:12 +0000 (19:16 -0800)]
fix release year for 5.40

6 months agotick off release 5.39.5
Karen Etheridge [Mon, 20 Nov 2023 03:10:55 +0000 (19:10 -0800)]
tick off release 5.39.5

6 months agofix markup for old epigraph
Karen Etheridge [Mon, 20 Nov 2023 03:10:21 +0000 (19:10 -0800)]
fix markup for old epigraph

6 months agoadd epigraph for 5.39.5 release
Karen Etheridge [Mon, 20 Nov 2023 03:10:13 +0000 (19:10 -0800)]
add epigraph for 5.39.5 release

6 months agoAdd new release to perlhist v5.39.5
Karen Etheridge [Mon, 20 Nov 2023 01:21:30 +0000 (17:21 -0800)]
Add new release to perlhist

6 months agoupdate github link regex
Karen Etheridge [Sat, 18 Nov 2023 23:51:27 +0000 (15:51 -0800)]
update github link regex

6 months agofinalize perldelta
Karen Etheridge [Mon, 20 Nov 2023 01:07:53 +0000 (17:07 -0800)]
finalize perldelta

6 months agoupdate Module::CoreList for 5.39.5
Karen Etheridge [Mon, 20 Nov 2023 00:56:02 +0000 (16:56 -0800)]
update Module::CoreList for 5.39.5

6 months agoadd missing perldelta entries for recent commits
Karen Etheridge [Sun, 19 Nov 2023 23:55:21 +0000 (15:55 -0800)]
add missing perldelta entries for recent commits

6abb319d6: Mention that the regex used by the empty m// is scoped
fbca05090: perl5300delta: mention removal of arybase module