# New Ticket Created by Bram Geron
# Please include the string: [perl #44363]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=44363 >
At Parrot exit, we force-destroy all PObjs. It can happen that a context
is destroyed after its sub is destroyed. Usually that's not a problem,
but if you run with -D80 (show when contexts are destroyed, and print
out the name of the sub) we may segfault, because the Parrot_sub
structure is already freed.
This patch fixes the segfault by turning off -D80 just before
force-freeing all PObjs.
inter_create.c | 8 ++++++++
1 file changed, 8 insertions(+)
This patch is unified after applying the patch from bug #44351. You
probably want to apply that first, or you will get warnings from patch(1).
--
Bram Geron | GPG 0xE7B9E65E
diff --git a/src/inter_create.c b/src/inter_create.c
index 307fa71..6a6c4aa 100644
--- a/src/inter_create.c
+++ b/src/inter_create.c
@@ -315,6 +315,14 @@ Parrot_really_destroy(PARROT_INTERP, SHIM(int exit_code), SHIM(void *arg))
interp->arena_base->DOD_block_level =
interp->arena_base->GC_block_level = 0;
+ if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
+ PIO_eprintf(interp, "We are about to exit and force-free subs, so turning off -D%x. It might\n"
+ "generate segfaults when we destroy a context of which the sub is already\n"
+ "dead.\n",
+ PARROT_CTX_DESTROY_DEBUG_FLAG);
+ Interp_debug_CLEAR(interp, PARROT_CTX_DESTROY_DEBUG_FLAG);
+ }
+
if (Interp_trace_TEST(interp, ~0)) {
PIO_eprintf(interp, "ParrotIO objects (like stdout and stderr) are about to be closed, so clearing trace flags.\n");
Interp_trace_CLEAR(interp, ~0);