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

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

Thread Previous | Thread Next
From:
Philippe M. Chiasson
Date:
September 30, 2006 13:59
Subject:
Re: [perl #40389] perl_destruct() leaks PL_defstash
Message ID:
6F342661-A51C-4EA6-B8BE-EB7059BADD8C@ectoplasm.org

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.

> If so, let me know and I'll do a detailed comparison of
> configurations to see if we can figure out what's going on.


$> 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;
$> ./Configure -des -Dusedevel -Doptimize=-g
$> make
$> LD_LIBRARY_PATH=$PWD PERL_DESTRUCT_LEVEL=1 ./perl  -e1
perl_destruct leaking a PL_defstash with refcnt=2
$> diff -u perl.c. 28908 perl.c
--- ../current@28908/perl.c     2006-09-24 18:27:48.000000000 -0700
+++ perl.c      2006-09-30 06:20:50.000000000 -0700
@@ -1062,6 +1062,10 @@

      hv = PL_defstash;
      PL_defstash = 0;
+    hv_clear(hv);
+    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;

$> LD_LIBRARY_PATH=$PWD PERL_DESTRUCT_LEVEL=1 ./perl  -e1

The thing that tells me it's an internal cycle somewhere in there is  
that clearing PL_defstash does bring down it's
refcount to 1.

I am running this on an uptodate Fedora Core 5 box:
$> uname -a
Linux activestate.com 2.6.17-1.2174_FC5smp #1 SMP Tue Aug 8 16:00:39  
EDT 2006 i686 i686 i386 GNU/Linux




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