develooper Front page | perl.perl5.porters | Postings from August 2008

Re: [perl #57174] Recursion memory leak when assignment in ifcondition

Thread Previous
From:
Bram
Date:
August 5, 2008 13:33
Subject:
Re: [perl #57174] Recursion memory leak when assignment in ifcondition
Message ID:
20080805223250.mpipc1qxkwc8osog@horde.wizbit.be
Citeren Thushan Abeysekera <perlbug-followup@perl.org>:

> # New Ticket Created by  "Thushan Abeysekera"
> # Please include the string:  [perl #57174]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57174 >
>
>
> This is a bug report for perl from thushan.abeysekera@computershare.com,
> generated with the help of perlbug 1.35 running under perl v5.8.6.
>
>
> -----------------------------------------------------------------
> There seems to be a memory leak when doing recursion with goto   
> &sub_name syntax.
> Run following two endless loops and check memory usage. While script  
>  1 runs out of memory, script 2 runs without a problem.
>
[snip]
> Originally observed in: perl, v5.8.6 built for MSWin32-x86-multi-thread
>
> This problem can be replicated in perl 5.10.0 i686-linux-thread-multi.
>
> Please check http://www.perlmonks.org/?node_id=698735 for a   
> discussion on this.
>

$ cat rt-57174.pl
#!/usr/bin/perl -l

use strict;
# use warnings;

my $mem1 = qx/ps u $$/;
my ($vsz1) = $mem1 =~ m/^perl\s+\d+\s+[0-9.]+\s+[0-9.]+\s+(\d+)/m;

my $m = 0;
test1();

my $mem2 = qx/ps u $$/;
my ($vsz2) = $mem2 =~ m/^perl\s+\d+\s+[0-9.]+\s+[0-9.]+\s+(\d+)/m;

if ($vsz1 + 1000 < $vsz2) {
   print "not ok ($vsz1 & $vsz2)";
}
else {
   print "ok";
}

sub test1 {
     my $v=0;
     if ($v = get_true()) {
         if ($m++ < 300_000) {
           goto &test1;
         }
     }
}

sub get_true {
     return 1;
}

__END__

(running with user 'perl')

perl-5.00504 rt-57174.pl
not ok (2708 & 14568)

perl-5.10.0 rt-57174.pl
not ok (3172 & 9144)

perl-blead@34156 rt-57174.pl
not ok (3196 & 9172)

(No access to a system with a perl before 5.00504 atm)

Kind regards,

Bram



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