Correct a long-standing ithreads reference counting anonamly - the
Nicholas Clark [Tue, 8 Jan 2008 16:42:31 +0000 (16:42 +0000)]
reference count only needs "doubling" when the scalar is pushed onto
PL_regex_padav for the second time.

p4raw-id: //depot/perl@32899

op.c
regexec.c
sv.c

diff --git a/op.c b/op.c
index af52a3a..2423bf0 100644 (file)
--- a/op.c
+++ b/op.c
@@ -624,7 +624,8 @@ clear_pmop:
 #ifdef USE_ITHREADS
        if(PL_regex_pad) {        /* We could be in destruction */
            ReREFCNT_dec(PM_GETRE(cPMOPo));
-            av_push((AV*) PL_regex_pad[0],(SV*) PL_regex_pad[(cPMOPo)->op_pmoffset]);
+            av_push((AV*) PL_regex_pad[0],
+                   (SV*) SvREFCNT_inc_simple_NN(PL_regex_pad[(cPMOPo)->op_pmoffset]));
             SvREADONLY_off(PL_regex_pad[(cPMOPo)->op_pmoffset]);
            SvREPADTMP_on(PL_regex_pad[(cPMOPo)->op_pmoffset]);
             PM_SETRE_OFFSET(cPMOPo, (cPMOPo)->op_pmoffset);
@@ -3373,7 +3374,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
        sv_setiv(repointer,0);
     } else {
        SV * const repointer = newSViv(0);
-       av_push(PL_regex_padav, SvREFCNT_inc_simple_NN(repointer));
+       av_push(PL_regex_padav, repointer);
        pmop->op_pmoffset = av_len(PL_regex_padav);
        PL_regex_pad = AvARRAY(PL_regex_padav);
     }
index 26c7a1a..9588cdf 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2259,7 +2259,7 @@ S_regtry(pTHX_ regmatch_info *reginfo, char **startpos)
                 /* so we know which PL_regex_padav element is PL_reg_curpm
                   when clearing up in perl_destruct() */
                 SvFLAGS(repointer) |= SVf_BREAK;
-                av_push(PL_regex_padav,repointer);
+                av_push(PL_regex_padav,SvREFCNT_inc_simple_NN(repointer));
                 PL_reg_curpm->op_pmoffset = av_len(PL_regex_padav);
                 PL_regex_pad = AvARRAY(PL_regex_padav);
             }
diff --git a/sv.c b/sv.c
index db63595..f8e18a9 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11273,8 +11273,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
            SV * const sv =
                SvREPADTMP(regex)
                    ? sv_dup_inc((SV*) regex, param)
-                   : SvREFCNT_inc(
-                       newSViv(PTR2IV(sv_dup_inc(INT2PTR(SV *, SvIVX(regex)), param))))
+                   : newSViv(PTR2IV(sv_dup_inc(INT2PTR(SV *, SvIVX(regex)), param)))
                ;
            if (SvFLAGS(regex) & SVf_BREAK)
                SvFLAGS(sv) |= SVf_BREAK; /* unrefcnted PL_curpm */