diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2004-01-20 00:16:42 +0000 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2004-01-20 00:16:42 +0000 |
commit | b36bdecab13f885c556206f71bfc47083b33107e (patch) | |
tree | cf1e451df96791b01c3da200598c5312387dbbcc /cop.h | |
parent | 1bf2966364b6356e9050b17d8920dd4a8ce27d97 (diff) | |
download | perl-b36bdecab13f885c556206f71bfc47083b33107e.tar.gz |
second attempt to fix [perl #24914] freeing a CV reference that was
currently being executed caused coredumps. The dounwind called by
die unwinds all the contexts on the context stack before unwinding
the save stack. To stop premature freeing of the CV, hold
references to it on both stacks.
p4raw-id: //depot/perl@22182
Diffstat (limited to 'cop.h')
-rw-r--r-- | cop.h | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -121,11 +121,20 @@ struct block_sub { PAD *oldcomppad; }; -/* base for the next two macros. Don't use directly */ +/* base for the next two macros. Don't use directly. + * Note that the refcnt of the cv is incremented twice; The CX one is + * decremented by LEAVESUB, the other by LEAVE. */ + #define PUSHSUB_BASE(cx) \ cx->blk_sub.cv = cv; \ cx->blk_sub.olddepth = CvDEPTH(cv); \ - cx->blk_sub.hasargs = hasargs; + cx->blk_sub.hasargs = hasargs; \ + if (!CvDEPTH(cv)) { \ + (void)SvREFCNT_inc(cv); \ + (void)SvREFCNT_inc(cv); \ + SAVEFREESV(cv); \ + } + #define PUSHSUB(cx) \ PUSHSUB_BASE(cx) \ |