This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_leavesub: reset SP in void context
authorDavid Mitchell <davem@iabyn.com>
Sun, 8 Nov 2015 15:05:01 +0000 (15:05 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:18:32 +0000 (09:18 +0000)
commit2e2d7405a2b751f778ee3118a87a5f31233efc77
treeae8de625038e71894d93650e6cecbc8024a968af
parent520275ba7f707faa538ca41c5a6af2cab8fb566a
pp_leavesub: reset SP in void context

In void context, pp_leavesub() doesn't bother resetting SP to the
base; either as an efficiency measure, or as an oversight (the other
pp_leavefoo functions do reset).

This is mostly harmless, as being void context, it's likely to immediately
execute pp_nextstate or similar, which will reset the stack anyway.
However with attributes, something like

    my @foo :attr = ()

causes attributes::import() to be called in void context, and whatever
dross it leaves on the stack becomes part of the assign, i.e. that assign
becomes the equivalent of:

    my (@foo, dross) = ()

which again is fairly harmless, if slightly inefficient.

However, the next commit should make pp_leavesub() call FRETMPS,
which means that 'dross' may now include freed SVs, which will make
pp_aassign choke.

This commit also requires ext/XS-APItest/t/call.t to be fixed.
Some tests in there (added years ago by myself) test the statu quo; that
is, it expects that calling call_sv(G_VOID) will leave return args on the
stack. Now it doesn't.
ext/XS-APItest/t/call.t
pp_hot.c