diff options
author | David Mitchell <davem@iabyn.com> | 2016-07-03 22:19:26 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-07-03 22:19:26 +0100 |
commit | cc040a9bd824f7d0dd1abf4940dff44fe71500f9 (patch) | |
tree | 5fdb01d112cb697c436c6915e80310d98c49f0f7 /pp_ctl.c | |
parent | 5993d6620f29d22b0a72701f4f0fdacff3d25460 (diff) | |
download | perl-cc040a9bd824f7d0dd1abf4940dff44fe71500f9.tar.gz |
Revert "FREETMPS when leaving eval, even when void/dying"
This reverts commit 214949f5cdc4164f25e32c1a6ce989286456c205.
It breaks Variable::Magic.
Temporarily revert while we work out what to do.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 38 |
1 files changed, 4 insertions, 34 deletions
@@ -1598,7 +1598,7 @@ Perl_qerror(pTHX_ SV *err) static void S_pop_eval_context_maybe_croak(pTHX_ PERL_CONTEXT *cx, SV *errsv, int action) { - SV *namesv = NULL; /* just to silence compiler warnings */ + SV *namesv; bool do_croak; CX_LEAVE_SCOPE(cx); @@ -1654,13 +1654,7 @@ Perl_die_unwind(pTHX_ SV *msv) if (in_eval) { I32 cxix; - /* We need to keep this SV alive through all the stack unwinding - * and FREETMPSing below, while ensuing that it doesn't leak - * if we call out to something which then dies (e.g. sub STORE{die} - * when unlocalising a tied var). So we do a dance with - * mortalising and SAVEFREEing. - */ - sv_2mortal(SvREFCNT_inc_simple_NN(exceptsv)); + exceptsv = sv_2mortal(SvREFCNT_inc_simple_NN(exceptsv)); /* * Historically, perl used to set ERRSV ($@) early in the die @@ -1729,24 +1723,6 @@ Perl_die_unwind(pTHX_ SV *msv) restartjmpenv = cx->blk_eval.cur_top_env; restartop = cx->blk_eval.retop; - - /* We need a FREETMPS here to avoid late-called destructors - * clobbering $@ *after* we set it below, e.g. - * sub DESTROY { eval { die "X" } } - * eval { my $x = bless []; die $x = 0, "Y" }; - * is($@, "Y") - * Here the clearing of the $x ref mortalises the anon array, - * which needs to be freed *before* $& is set to "Y", - * otherwise it gets overwritten with "X". - * - * However, the FREETMPS will clobber exceptsv, so preserve it - * on the savestack for now. - */ - SAVEFREESV(SvREFCNT_inc_simple_NN(exceptsv)); - FREETMPS; - /* now we're about to pop the savestack, so re-mortalise it */ - sv_2mortal(SvREFCNT_inc_simple_NN(exceptsv)); - /* Note that unlike pp_entereval, pp_require isn't supposed to * trap errors. So if we're a require, after we pop the * CXt_EVAL that pp_require pushed, rethrow the error with @@ -4329,11 +4305,8 @@ PP(pp_leaveeval) ? SvTRUE(*PL_stack_sp) : PL_stack_sp > oldsp); - if (gimme == G_VOID) { + if (gimme == G_VOID) PL_stack_sp = oldsp; - /* free now to avoid late-called destructors clobbering $@ */ - FREETMPS; - } else leave_adjust_stacks(oldsp, oldsp, gimme, 0); @@ -4422,11 +4395,8 @@ PP(pp_leavetry) oldsp = PL_stack_base + cx->blk_oldsp; gimme = cx->blk_gimme; - if (gimme == G_VOID) { + if (gimme == G_VOID) PL_stack_sp = oldsp; - /* free now to avoid late-called destructors clobbering $@ */ - FREETMPS; - } else leave_adjust_stacks(oldsp, oldsp, gimme, 1); CX_LEAVE_SCOPE(cx); |