summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2004-01-20 00:16:42 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-01-20 00:16:42 +0000
commitb36bdecab13f885c556206f71bfc47083b33107e (patch)
treecf1e451df96791b01c3da200598c5312387dbbcc /cop.h
parent1bf2966364b6356e9050b17d8920dd4a8ce27d97 (diff)
downloadperl-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.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/cop.h b/cop.h
index 2e30eafb66..3d1191c9bb 100644
--- a/cop.h
+++ b/cop.h
@@ -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) \