summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-12-05 12:53:30 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-12-05 21:31:42 -0800
commit230834321e308444d408bdbf755d181b67e82d4c (patch)
tree0775daf798c8ecb31604e073e21eeba3a65b9375 /op.c
parentbcea25a760263ce058f5588c6ae62af6f09a211e (diff)
downloadperl-230834321e308444d408bdbf755d181b67e82d4c.tar.gz
Stop renamed packages from making reset() crash
This only affected threaded builds. I think the comments in the added test explain well enough what was happening. The solution is to store a stashpad offset in the pmop, instead of the name of the stash. This is similar to what was done with cop stashes in d4d03940c58a. Not only does this fix the crash, but it also makes compilation faster and saves memory (no separate malloc for every m?pat?). I had to move Safefree(PL_stashpad) later on in perl_destruct, because freeing a pmop causes the PL_stashpad to be accessed, and pmops can be freed during sv_clean_all. Its previous location was not a problem for cops, as PL_stashpad[cop->cop_stashoff] is only accessed when PL_curcop==that_cop and Perl code is running, not when cops are freed.
Diffstat (limited to 'op.c')
-rw-r--r--op.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/op.c b/op.c
index 15930b62a7..766ca190ab 100644
--- a/op.c
+++ b/op.c
@@ -654,12 +654,6 @@ S_op_destroy(pTHX_ OP *o)
FreeOp(o);
}
-#ifdef USE_ITHREADS
-# define forget_pmop(a,b) S_forget_pmop(aTHX_ a,b)
-#else
-# define forget_pmop(a,b) S_forget_pmop(aTHX_ a)
-#endif
-
/* Destructor */
void
@@ -877,7 +871,7 @@ clear_pmop:
if (!(cPMOPo->op_pmflags & PMf_CODELIST_PRIVATE))
op_free(cPMOPo->op_code_list);
cPMOPo->op_code_list = NULL;
- forget_pmop(cPMOPo, 1);
+ forget_pmop(cPMOPo);
cPMOPo->op_pmreplrootu.op_pmreplroot = NULL;
/* we use the same protection as the "SAFE" version of the PM_ macros
* here since sv_clean_all might release some PMOPs
@@ -920,9 +914,6 @@ S_cop_free(pTHX_ COP* cop)
STATIC void
S_forget_pmop(pTHX_ PMOP *const o
-#ifdef USE_ITHREADS
- , U32 flags
-#endif
)
{
HV * const pmstash = PmopSTASH(o);
@@ -955,10 +946,6 @@ S_forget_pmop(pTHX_ PMOP *const o
}
if (PL_curpm == o)
PL_curpm = NULL;
-#ifdef USE_ITHREADS
- if (flags)
- PmopSTASH_free(o);
-#endif
}
STATIC void
@@ -974,7 +961,7 @@ S_find_and_forget_pmops(pTHX_ OP *o)
case OP_PUSHRE:
case OP_MATCH:
case OP_QR:
- forget_pmop((PMOP*)kid, 0);
+ forget_pmop((PMOP*)kid);
}
find_and_forget_pmops(kid);
kid = kid->op_sibling;