This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ss_dup: make new savestack have SS_MAXPUSH extra
authorDavid Mitchell <davem@iabyn.com>
Tue, 5 Apr 2016 08:26:21 +0000 (09:26 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 5 Apr 2016 08:26:21 +0000 (09:26 +0100)
commit726368e016b611dfdf44e3a9a53e572b2e25de73
tree83abc84d2b79cafd33130c5867136c0f6a5aa94f
parent19949523b593c5b1e189da235f8065e235ee68e0
ss_dup: make new savestack have SS_MAXPUSH extra

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.
sv.c