Skip to content

Commit

Permalink
Massive hack for closures over main_root
Browse files Browse the repository at this point in the history
  • Loading branch information
rafl committed Nov 4, 2010
1 parent 3c40b2b commit 9ef9e75
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Clean.xs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ eval (PerlInterpreter *perl, const char *code)
ret = ERRSV;
}

/* Some closures can reference the main program as their OUTSIDE. Cloning
* that doesn't quite do what we'd want it to. Therefore we just toggle some
* of its bits so things only go wrong during global destruction, not during
* normal garbage collection on LEAVE. The proper fix for this is probably
* to remove the cloning main_root limitations from the core. */
if (SvROK(ret) && SvTYPE(SvRV(ret)) == SVt_PVCV) {
CV *outside = CvOUTSIDE(SvRV(ret));

if (outside && SvTEMP(outside) && CvUNIQUE(outside) && !SvFAKE(outside))
SvTEMP_off(outside);
}

SET_PERL(prev);

#if (PERL_VERSION < 13) || (PERL_VERSION == 13 && PERL_SUBVERSION <= 1)
Expand Down

0 comments on commit 9ef9e75

Please sign in to comment.