fix yet another USE_THREADS leak due to failure to free stacks
Gurusamy Sarathy [Sat, 18 Jul 1998 08:48:13 +0000 (08:48 +0000)]
p4raw-id: //depot/perl@1531

ext/Thread/Thread.xs
util.c

index 5d47cd0..34aee1b 100644 (file)
@@ -150,11 +150,20 @@ threadstart(void *arg)
     SvREFCNT_dec(thr->errsv);
     SvREFCNT_dec(thr->errhv);
 
+    /*Safefree(cxstack);*/
+    while (curstackinfo->si_next)
+       curstackinfo = curstackinfo->si_next;
+    while (curstackinfo) {
+       PERL_SI *p = curstackinfo->si_prev;
+       SvREFCNT_dec(curstackinfo->si_stack);
+       Safefree(curstackinfo->si_cxstack);
+       Safefree(curstackinfo);
+       curstackinfo = p;
+    }    
     Safefree(markstack);
     Safefree(scopestack);
     Safefree(savestack);
     Safefree(retstack);
-    Safefree(cxstack);
     Safefree(tmps_stack);
     Safefree(ofs);
 
@@ -165,6 +174,7 @@ threadstart(void *arg)
     Safefree(screamnext);
     Safefree(reg_start_tmp);
     SvREFCNT_dec(lastscream);
+    /*SvREFCNT_dec(defoutgv);*/
 
     MUTEX_LOCK(&thr->mutex);
     DEBUG_L(PerlIO_printf(PerlIO_stderr(),
diff --git a/util.c b/util.c
index eb52ee5..af6f137 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2784,7 +2784,7 @@ new_struct_thread(struct perl_thread *t)
     curpm = t->Tcurpm;         /* XXX No PMOP ref count */
     nrs = newSVsv(t->Tnrs);
     rs = SvREFCNT_inc(nrs);
-    last_in_gv = (GV*)SvREFCNT_inc(t->Tlast_in_gv);
+    last_in_gv = Nullgv;
     ofslen = t->Tofslen;
     ofs = savepvn(t->Tofs, ofslen);
     defoutgv = (GV*)SvREFCNT_inc(t->Tdefoutgv);