[perl #122771] Fix assertion failure with -d and sort

-d was conflicting with sort optimisations added by 932bca295d, which
had assertions that checked for nextstate, but not dbstate ops.

(cherry picked from commit 4c627877a44535772b40aca390861295b62b1f6d)
[perl #122995] Hang with while(1) in a sub-list

It was hanging at compile time in some cases, e.g.:

sub foo { () = ($a, my $b, ($c, do { while(1) {} })) }

The optimisation added in 5.20 to turn list+pushmark into null ops
when they are in list context (effectively making ($a,($b,$c)) equiva-
lent to ($a,$b,$c) with regard to which ops are executed) followed
op_next pointers to find the last op that was a kid of the sublist.

You can’t just follow op_next pointers like that, because it will loop
at compile time on infinite loops like while (1){}.

In this case, the last kid was being found in order to elide the erst-
while list op from the op_next chain, but that is not necessary, since
later OP_NULL handling takes care of it anyway.

(cherry picked from commit 0d42e778cfa0ef9c7315b82e62a6c9fe0cb1cec5)
PATCH: [perl #123198] Memory leak in regex in 5.20.1

The SV was declared temporary but the pointer to it was getting changed
to another SV under some circumstances and the reference to that wasn't
getting decremented.  The temporary stemmed from earlier code and was no
longer needed.  Now, an explicit reference decrement is always done.

(cherry picked from commit 512e01ab009bc6309309e05891effe8ae3c0e9da)
perl #122747: localize PL_curpm to null in _core_swash_init

Set PL_curpm to null before we do any swash intialization
in _core_swash_init(). This "hides" the current regop from the
swash code, with the intent of prevent weird reentrancy bugs
when the swashes are initialized.

Long term you could argue that we should just not use the regex
engine to initialize a swash, and then this would be unnecessary.

Thanks to FC for the suggestion!

(cherry picked from commit 2c1f00b9036a7987c714a407662651ef7da99495)
[perl #123029]: add regression test

This bug was fixed in c0683843e9299db25f354e2c8c90faa7614950d1.
(cherry picked from commit c4a33ecd3009146ea545628e3014a22c637b6bb1)

(cherry picked from commit 60eaf23b013ea62d010333c18283f269a49e6e3b)
state.t: Improve test for #123029

This version fails in 5.20.1 whether COW is enabled or not.
(cherry picked from commit a4f1ca6eb9658c4d589c98787f06e1851909c7d5)

(cherry picked from commit 029988317d165cb2c0c7f73581bb70d358c56458)
sv.c: Always #define COW threshold constants

They are also used in determining whether an operator target (PADTMP)
should be swiped.

If COW is not enabled, then the #if SV_COW_THRESHOLD ends up treating
the threshold as 0, which means swiping almost always happens for tar-
gets, resulting in an increase in malloc calls.  So non-COW builds end
up slower than they need to be.  This also caused bug #123029 to occur
more often under non-COW builds.
(cherry picked from commit 9f53080ae514a42899f88743c9a5113d4677e9f6)

(cherry picked from commit e75eea488c53a9119ff147eb256afee551927d2f)
[perl #123029] Don’t steal PADSTALE buffers

9ffd39ab was supposed to steal buffers only from PADTMP SVs,
but PADTMP and PADSTALE share the same bit, PADMY mediating
between the two meanings.  So we need to check the PADMY flag
as well.

(cherry picked from commit d385684951d4e1197c32ad0f4371c5255766a34d)
Fix crash when lex subs are used for AUTOLOAD

(cherry picked from commit 18691622911f2e18df42a5a98ea4c42386f4e558)
Fix crash when lex subs are used for overload

(cherry picked from commit 56117e3ef4ef2c7986c400f86f321f22f261571a)
Fix crash with lex subs under -d

(cherry picked from commit 9d8e4b9b32800eb499d83442ce8bbe6639773936)
perldelta for f20d0df0f

(cherry picked from commit 1699f5c257bc554753cc4ddf10c62ac8a5c338ff)
Correct usage of memEQs in attributes.xs [perl #122701]

Reported and diagnosed by Reini Urban <rurban@cpanel.net>.  The call to
memEQs(name, 6, "shared") could fail if name were shorter than 6 bytes,
or if name were longer than 6, but started with "shared".

(cherry picked from commit dd369969a58d736f281ffebe36fc24ab45b29fa6)
[perl #122669] Don’t taint at compile time

 #!perl -T

 # tainted constant
 use constant K=>$^X;

 # Just reading the constant for the sake of folding can enabled
 # taintedness at compile time.
 0 if K;

 # Taintedness is still on when the ‘strict.pm’ SV is created, so
 # require croaks on it (‘Insecure dependency’).
 use strict;

The fix is simply not to propagate taintedness at compile time.
Hence, the value of K will still be tainted at run time (require(K)
croaks), but just reading the value of K at compile time won’t taint
subsequent string literals (or barewords treated as strings).

‘Compile time’ here is relative:  Taintedness still wafts about as
usual when BEGIN blocks are executed, because code is actually run-
ning.  It’s when code is being parsed that propagation is disabled.

The reason taint propagation could span across statements at compile
time was that *execution* of a new statement resets taintedness,
whereas parsing is oblivious to it.

(cherry picked from commit 64ff300be0f7714585466af5bb87b2e37db5082a)
Fix t/op/taint.t on Windows

$ENV{PATH} seems to be the problem.  If we clear it, then we can’t
spawn another process.  I am basing this solely on this comment ear-
lier in the file:

    # On Windows we can't spawn a fresh Perl interpreter unless at
    # least the Windows system directory (usually C:\Windows\System32)
    # is still on the PATH.  There is however no way to determine the
    # actual path on the current system without loading the Win32
    # module, so we just restore the original $ENV{PATH} here.

(cherry picked from commit eaff586aa6444fb20654ed863b7ff35e136737e8)
IRIX 6.5 (cc 7.4) needs -c99 to compile without whining.

Without -c99 including C99 header files like <stdint.h> is an error.

For gcc (used "freeware" 3.3), there just doesn't seem to be a way,
so claim there's no <stdint.h>.

(cherry picked from commit 0b6ebfadd8d2cfccc07203e94d583721305fd779)
(cherry picked from commit 975d2fd592d346222f39bd6e412e239d95547fd5)
Irix: MIPSpro 7.4 compiler has broken memcmp.

(Supposedly 7.4.1m is okay in this regard, and there is also 7.5.)

The commit that 'broke' Perl build on IRIX was 57620943
which of course wasn't to blame, the IRIX compiler was.
(Symptom: miniperl crashing, can be narrowed to just /[[:alpha:]]/)

Furthermore: IRIX build was also earlier broken for a long time by
another problem (in the preprocessor), see for example perl #33849.
(Symptom: compile failing in gv.c RvDEEPCP)

Summary: building Perls on IRIX needs either this very commit,
or undoing the 57620943 (for the memcmp brokenness), and possibly
applying both the c297d531 and 08c5d564 (for the cpp brokenness).
(The latter were applied between 5.10.0 and 5.10.1.)

(cherry picked from commit 1764d98bf44052060e2fe7cfa940d4ffc19f5961)
(cherry picked from commit 4a52caae380c672b6e0556ad01a26f42bccb9991)
Irix: the explicit <fcntl.h> is needed

(cherry picked from commit 5b96080c2232c4c22364c08f21c03d491dba7474)
(cherry picked from commit 21fa3204820447ae44d32bba040426b98f3f8c74)
Tru64: _SOCKADDR_LEN is good.

Declare it as early as possible.  The earlier position lead into
getting a mix of different APIs with mismatching sockadddrs.

(cherry picked from commit 0befe6f120ed237c1658f27caa9950f1e21ef40b)
(cherry picked from commit ef2b4ea7253ba96c3813457180a659c28e1927b4)
Tru64: does have sa_len.

(cherry picked from commit ec015202b887bc1ede4b6538364b88eb80c4956d)
(cherry picked from commit 8ca2318934742961ce8ead487c0bf8f235f2b18b)