This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #113872] Fix leavewrite’s stack handling
authorFather Chrysostomos <sprout@cpan.org>
Thu, 26 Jul 2012 07:16:00 +0000 (00:16 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 26 Jul 2012 07:23:12 +0000 (00:23 -0700)
commit43cd5cb7e818c8635f51ef56a15b50d3dadbc735
tree63f4e95cabe8636fbc65200439589bfde7df55e5
parent99a1d0d13934e829126ea4d0e61887470d8138e5
[perl #113872] Fix leavewrite’s stack handling

This commit fixes Scope::Escape compatibility by restoring the old
stack pointer stored on the context stack when exiting a write.

I don’t really understand why this fixes Scope::Escape, or rather, how
Scope::Escape ends up leaving some number of items on the stack other
than 1.  But I *do* know this is the correct approach, as it mirrors
what pp_leavesub does in scalar context, but pops the stack back
to the old value (SP = newsp), rather than the old value+1 (see
pp_hot.c:pp_leavesub: MARK = newsp + 1; and later SP = MARK;).  Then
the code that follows takes care of pushing write’s own return value.
pp_sys.c