summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-07-01 20:19:23 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 08:59:34 +0000
commit72f28af4674d41a7b1c2a7eaa67360e5e2f32477 (patch)
treed6fc25b2601c5f4caa5123b0a822c2531738fce3 /pp.c
parentf72bdec314663b4b71182ffdae79bb35de3a4a5a (diff)
downloadperl-72f28af4674d41a7b1c2a7eaa67360e5e2f32477.tar.gz
pp_entersub: skip resetting @_
Whenever we leave a sub by whatever means (pp_leavesub, pp_return, pp_goto, die etc) it is the responsibility of the code that pops the SUB context to clean up the private @_ of that sub (i.e pad[0]) so that it's empty and not real. There's some code in pp_entersub that duplicates this check. I believe this check is unnecessary and so this commit removes it and replaces it with an assert. It was added by 221373f04 in 1999 to fix the issue described in Subject: [ID 19991015.010] [BUG 5.005_62 Assertation failed: "pp_ctl.c" line 2443] Message-Id: <19991016024500.A32541@athens.aocn.com> There were two fixes applied for this issue; the other was 0253cb4. I think the second commit actually fixed the issue and the first fix was a red herring. If my newly-added assert fails, it implies that something needs fixing in the context-popping code, rather than in pp_entersub. In fact the new assert showed up one issue: the special-case handling of @_ for &CORE::undef in pp_coreargs wasn't emptying the array, so I added a CLEAR_ARGARRAY().
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index 30a2dd0569..8900706160 100644
--- a/pp.c
+++ b/pp.c
@@ -6440,15 +6440,19 @@ PP(pp_coreargs)
if (opnum == OP_UNDEF && SvRV(*svp) == (SV *)PL_defgv
&& cxstack[cxstack_ix].cx_type & CXp_HASARGS) {
/* Undo @_ localisation, so that sub exit does not undo
- part of our undeffing. */
+ part of our undeffing.
+ this corresponds to the part of POPSUB that
+ does @_ cleanup */
PERL_CONTEXT *cx = &cxstack[cxstack_ix];
+ AV *av = MUTABLE_AV(PAD_SVl(0));
POP_SAVEARRAY();
cx->cx_type &= ~ CXp_HASARGS;
assert(AvARRAY(MUTABLE_AV(
PadlistARRAY(CvPADLIST(cx->blk_sub.cv))[
CvDEPTH(cx->blk_sub.cv)])) == PL_curpad);
- assert(!AvREAL(MUTABLE_AV(PAD_SVl(0))));
+ assert(!AvREAL(av));
+ CLEAR_ARGARRAY(av);
}
}
break;