This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #119311] Keep CvDEPTH and savestack in sync
authorFather Chrysostomos <sprout@cpan.org>
Tue, 27 Aug 2013 06:21:26 +0000 (23:21 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 27 Aug 2013 07:13:07 +0000 (00:13 -0700)
commit25375124d2a06f2525e94c98c36eea007026778e
tree1fb76629bd05b31c30dfcda892fbbfcd4288f17b
parent31d073689e2b5fa63aa7d4f8aaf529f75eeb5d0e
[perl #119311] Keep CvDEPTH and savestack in sync

when unwinding sub and format calls.

The comments in the added test file explain what the problem is.

The fix is to call LEAVE_SCOPE in POPSUB and POPFORMAT (to free their
lexicals) before lowering CvDEPTH.

If the context has already been popped via cxstack_ix--, then
LEAVE_SCOPE could overwrite it, so accessing cx after LEAVE_SCOPE is
unsafe.  Hence the changes to POPSUB and POPFORMAT are a bit involved.
Some callers of POPSUB do a temporary cxstack_ix++ first so they
can access cx afterwards.  Two cases needed to be changed to
work that way.
MANIFEST
cop.h
pp_ctl.c
pp_hot.c
pp_sys.c
t/op/rt119311.t [new file with mode: 0644]