During normal exit from an eval, both POPEVAL and LEAVE are done,
meaning that the context stack and save stack are unwound in lockstep.
However, during an exception, dounwind() does the POPEVAL but not the
LEAVE, leaving them temporarily out of step.
About a 2 years ago, with v5.19.3-139-g2537512, subs and formats were
changed so that the save stack popping was done in sync in dounwind.
This commit extends that to evals too.
I'm doing this principally so that PL_compad will always be restored at
the correct moment, which will shortly allow me to eliminate the argarray
field from the context struct.
NB: unlike POPSUB and POPFORMAT, I've added the LEAVE_SCOPE to dounwind
rather than directly adding to the POPEVAL macro - this is because the
various places that use POPEVAL typically use it earlier than the
comparable places with POPSUB, which means they aren't ready to pop the
save stack yet.
NNB: The LEAVE_SCOPE can't be extended to all context types in dounwind(),
only to sub-ish types - specifically the types that can be 'return'ed from.
This is because if you 'return' from a sub or eval, pp_return will
unwind all contexts down to the next sub or eval (discarding all the loops
etc that it escaping out of), but the args it is returning shouldn't
be prematurely freed.
break;
case CXt_EVAL:
POPEVAL(cx);
+ LEAVE_SCOPE(PL_scopestack[cx->blk_oldscopesp-1]);
break;
case CXt_LOOP_LAZYIV:
case CXt_LOOP_LAZYSV:
SvPVX_const(namesv),
SvUTF8(namesv) ? -(I32)SvCUR(namesv) : (I32)SvCUR(namesv),
G_DISCARD);
+ LEAVE_with_name("eval");
Perl_die(aTHX_ "%"SVf" did not return a true value", SVfARG(namesv));
NOT_REACHED; /* NOTREACHED */
/* die_unwind() did LEAVE, or we won't be here */