develooper Front page | perl.perl5.porters | Postings from October 2006

Re: [perl #40389] perl_destruct() leaks PL_defstash

Thread Previous
From:
Andy Dougherty
Date:
October 6, 2006 06:45
Subject:
Re: [perl #40389] perl_destruct() leaks PL_defstash
Message ID:
Pine.LNX.4.62.0610060938440.31589@fractal.phys.lafayette.edu
On Sat, 30 Sep 2006, Philippe M. Chiasson wrote:

> 
> On 25-Sep-06, at 6:34 AM, Andy Dougherty wrote:
> 
> > On Thu, 21 Sep 2006, gozer @ activestate . com wrote:
> > 
> > > # New Ticket Created by  gozer@activestate.com
> > > # Please include the string:  [perl #40389]
> > > # in the subject line of all future correspondence about this issue.
> > > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40389 >
> > > 
> > 
> > > In perl_destruct():
> > > 
> > > 1061:    /* Prepare to destruct main symbol table.  */
> > > 1062:
> > > 1063:    hv = PL_defstash;
> > > 1064:    PL_defstash = 0;
> > > 1065:    SvREFCNT_dec(hv); /* At this point, SvREFCNT(hv) is 2 */
> > > 1066:    SvREFCNT_dec(PL_curstname);
> > > 
> > > It would seem it's caused by a self-reference somewhere, since adding
> > > hv_clear(hv) before the call to SvREFCNT_dec() brings the refcnt down
> > > to 1.
> > > 
> > > $> perl -e1
> > > perl_destruct leaking a PL_defstash with refcnt=2
> > > 
> > > is enough to demonstrate this bug
> > 
> > I can't reproduce this with today's perl 5.9.x, patchlevel 28890.  Are you
> > still seeing it?
> 
> That particular code path needs a PERL_DESTRUCT_LEVEL >= 1 to be exercised.
> I should have mentionned it before.

Ah.  Yes, that would have helped.

> $> cat .patch
> 28908
> $> diff -u perl.c. 28908 perl.c
> --- .perl.c.28908     2006-09-24 18:27:48.000000000 -0700
> +++ perl.c      2006-09-30 06:14:30.000000000 -0700
> @@ -1062,6 +1062,9 @@
> 
>      hv = PL_defstash;
>      PL_defstash = 0;
> +    if (SvREFCNT(hv) > 1) {
> +        Perl_warner(aTHX_ packWARN(WARN_INTERNAL), "perl_destruct leaking a
> %s with refcnt=%d\n", "PL_defstash", SvREFCNT(hv));
> +    }
>      SvREFCNT_dec(hv);
>      SvREFCNT_dec(PL_curstname);
>      PL_curstname = NULL;

Ah.  Having that in hand would have helped too.  (Alas this patch didn't 
apply cleanly for me, but I see what you're doing.)

Yes, with your patch I now see the error message you cited. No, I don't 
see offhand what to do about it :-(.

-- 
    Andy Dougherty		doughera@lafayette.edu

Thread Previous


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