develooper Front page | perl.perl5.porters | Postings from March 2001

Re: my purify runs with 5.6.1-to-be

Thread Previous | Thread Next
From:
Radu Greab
Date:
March 16, 2001 14:22
Subject:
Re: my purify runs with 5.6.1-to-be
Message ID:
15026.37402.195897.205252@ix.netsoft.ro
On Fri, 16 Mar 2001 15:58 -0600, Jarkko Hietaniemi wrote:
 > > What I found is that in clear_pmop PmopSTASH(cPMOPo) is corrupt, I
 > > guess because it was already cleared. HvPMROOT(pmstash) returns
 > > garbage and we get the coredump.
 > > 
 > > Changing this line in Sarathy's patch from
 > > 
 > >  clear_pmop:
 > > +	{
 > > +	    HV *pmstash = PmopSTASH(cPMOPo);
 > > +	    if (pmstash) {
 > > 
 > > to
 > > 
 > > +	    if (pmstash && SvREFCNT(pmstash)) {
 > > 
 > > stops the coredumps but I'm not sure if SvREFCNT(pmstash) is to be trusted
 > > if pmstash was already cleared.
 > 
 > This change makes my core dumps go away, too.

I'm trying a new patch based on the following idea: if we are going to 
add to PMOP struct a new member just for the sake of reset, why not
use in this case a double linked list?

The patch may need more work as I get

lib/dosglob..........Scalars leaked: 1
ok

after applying it.


Thanks,
Radu Greab

--- op.h~	Mon Mar 12 12:24:04 2001
+++ op.h	Sat Mar 17 00:12:12 2001
@@ -242,6 +242,7 @@
     U16		op_pmflags;
     U16		op_pmpermflags;
     U8		op_pmdynflags;
+    PMOP *	op_pmprev;		/* double link scanpats for reset */
 };
 
 #define PMdf_USED	0x01		/* pm has been used once already */
--- op.c~	Wed Mar 14 09:31:10 2001
+++ op.c	Sat Mar 17 00:15:32 2001
@@ -842,6 +842,14 @@
     case OP_MATCH:
     case OP_QR:
 clear_pmop:
+	{
+	    PMOP *prev = cPMOPo->op_pmprev, *next = cPMOPo->op_pmnext;
+	    if (prev)
+		prev->op_pmnext = cPMOPo->op_pmnext;
+	    if (next)
+		next->op_pmprev = cPMOPo->op_pmprev;
+	    cPMOPo->op_pmprev = cPMOPo->op_pmnext = (PMOP*)Nullop;
+	}
 	cPMOPo->op_pmreplroot = Nullop;
 	ReREFCNT_dec(cPMOPo->op_pmregexp);
 	cPMOPo->op_pmregexp = (REGEXP*)NULL;
@@ -2903,7 +2911,11 @@
 
     /* link into pm list */
     if (type != OP_TRANS && PL_curstash) {
-	pmop->op_pmnext = HvPMROOT(PL_curstash);
+	PMOP *next = HvPMROOT(PL_curstash);
+	if (next)
+	    next->op_pmprev = pmop;
+	pmop->op_pmnext = next;
+	pmop->op_pmprev = (PMOP*)Nullop;
 	HvPMROOT(PL_curstash) = pmop;
     }
 



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About