This fixes RT #perl #127799
My commit v5.23.7-261-g3caf026 made PL_savestack_max claim to have
allocated less than had actually been claimed (by a margin of SS_MAXPUSH).
This made the 'check whether the stack needs extending code' slightly
simpler, and errs on the side of safety. Except:
Perl_ss_dup(), when duplicating the savestack, makes the new stack
PL_savestack_max in size, which is large enough to duplicate the existing
stack, but the new stack no longer has a SS_MAXPUSH margin at the top.
The dSS_ADD family of macros work by assuming there is always such a
margin: they push their args onto the stack and only then check whether
the stack needs growing. This makes the code much more efficient, but of
course breaks if no margin is present.
{
dVAR;
ANY * const ss = proto_perl->Isavestack;
- const I32 max = proto_perl->Isavestack_max;
+ const I32 max = proto_perl->Isavestack_max + SS_MAXPUSH;
I32 ix = proto_perl->Isavestack_ix;
ANY *nss;
const SV *sv;