From: Robin Houston Date: Sat, 19 May 2001 16:19:34 +0000 (+0100) Subject: Re: CvFILE corruption under ithreads X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a636914a235cd8650ed6efcb07e302c0332fa638;p=p5sagit%2Fp5-mst-13.2.git Re: CvFILE corruption under ithreads Message-ID: <20010519161934.A12751@puffinry.freeserve.co.uk> p4raw-id: //depot/perl@10925 --- diff --git a/cv.h b/cv.h index 4ade508..7fa9400 100644 --- a/cv.h +++ b/cv.h @@ -55,6 +55,11 @@ Returns the stash of the CV. #define CvXSUBANY(sv) ((XPVCV*)SvANY(sv))->xcv_xsubany #define CvGV(sv) ((XPVCV*)SvANY(sv))->xcv_gv #define CvFILE(sv) ((XPVCV*)SvANY(sv))->xcv_file +#ifdef USE_ITHREADS +# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = savepv(CopFILE(cop))) +#else +# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = CopFILE(cop)) +#endif #define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv)) #define CvDEPTH(sv) ((XPVCV*)SvANY(sv))->xcv_depth #define CvPADLIST(sv) ((XPVCV*)SvANY(sv))->xcv_padlist diff --git a/op.c b/op.c index 2228289..913f196 100644 --- a/op.c +++ b/op.c @@ -4153,6 +4153,13 @@ Perl_cv_undef(pTHX_ CV *cv) } #endif /* USE_THREADS */ +#ifdef USE_ITHREADS + if (CvFILE(cv) && !CvXSUB(cv)) { + Safefree(CvFILE(cv)); + CvFILE(cv) = 0; + } +#endif + if (!CvXSUB(cv) && CvROOT(cv)) { #ifdef USE_THREADS if (CvDEPTH(cv) || (CvOWNER(cv) && CvOWNER(cv) != thr)) @@ -4298,7 +4305,12 @@ S_cv_clone2(pTHX_ CV *proto, CV *outside) MUTEX_INIT(CvMUTEXP(cv)); CvOWNER(cv) = 0; #endif /* USE_THREADS */ +#ifdef USE_ITHREADS + CvFILE(cv) = CvXSUB(proto) ? CvFILE(proto) + : savepv(CvFILE(proto)); +#else CvFILE(cv) = CvFILE(proto); +#endif CvGV(cv) = CvGV(proto); CvSTASH(cv) = CvSTASH(proto); CvROOT(cv) = OpREFCNT_inc(CvROOT(proto)); @@ -4732,7 +4744,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) } } CvGV(cv) = gv; - CvFILE(cv) = CopFILE(PL_curcop); + CvFILE_set_from_cop(cv, PL_curcop); CvSTASH(cv) = PL_curstash; #ifdef USE_THREADS CvOWNER(cv) = 0; @@ -5110,7 +5122,7 @@ Perl_newFORM(pTHX_ I32 floor, OP *o, OP *block) cv = PL_compcv; GvFORM(gv) = cv; CvGV(cv) = gv; - CvFILE(cv) = CopFILE(PL_curcop); + CvFILE_set_from_cop(cv, PL_curcop); for (ix = AvFILLp(PL_comppad); ix > 0; ix--) { if (!SvPADMY(PL_curpad[ix]) && !SvIMMORTAL(PL_curpad[ix]))