Skip to content
Browse files

Sever nexuses at the start of global destruction

The testsuite no longer segfaults, although it does leak memory (4 words per
interpreter created).
  • Loading branch information...
1 parent 64df29f commit cca07ac031eb84be549209970e80c98103846050 @sorear sorear committed
Showing with 9 additions and 1 deletion.
  1. +3 −0 src/pmc/bkmarshal.c
  2. +1 −0 src/pmc/bkmarshal.h
  3. +3 −0 src/pmc/p5interpreter.pmc
  4. +2 −1 src/pmc/p5sv.pmc
View
3 src/pmc/bkmarshal.c
@@ -309,6 +309,9 @@ XS(blizkost_callable_trampoline)
blizkost_get_bound_pmc(my_perl, &nexus, (SV *)cv, &callable);
+ if (nexus->dying)
+ exit_fatal(1, "Attempted reentry of Parrot code during global destruction");
+
PERL_UNUSED_VAR(ax);
SP -= items;
PUTBACK;
View
1 src/pmc/bkmarshal.h
@@ -23,6 +23,7 @@ typedef struct blizkost_nexus {
PerlInterpreter *my_perl;
Parrot_Interp parrot_interp;
PMC *p5i;
+ int dying;
} blizkost_nexus;
#define BLIZKOST_NEXUS blizkost_nexus *nexus
View
3 src/pmc/p5interpreter.pmc
@@ -87,6 +87,7 @@ Set up P5Interpreter PMC.
SET_ATTR_nexus(interp, SELF, nexus);
nexus->parrot_interp = interp;
nexus->p5i = SELF;
+ nexus->dying = 0;
/* We turn on auto-flush to avoid oddness in interactions between
* IO systems. */
@@ -106,6 +107,8 @@ Destructor for the P5Interpreter PMC.
struct blizkost_nexus *nexus = PARROT_P5INTERPRETER(SELF)->nexus;
dBNPERL;
+ nexus->dying = 1;
+
perl_destruct(my_perl);
perl_free(my_perl);
View
3 src/pmc/p5sv.pmc
@@ -67,7 +67,8 @@ Decrement reference count of held SV.
SV *sv = PARROT_P5SV(SELF)->sv;
dBNPERL;
- SvREFCNT_dec(sv);
+ if (!nexus->dying)
+ SvREFCNT_dec(sv);
}
}

0 comments on commit cca07ac

Please sign in to comment.
Something went wrong with that request. Please try again.