Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursion memory leak when assignment in if condition #9426

Open
p5pRT opened this issue Jul 21, 2008 · 5 comments
Open

Recursion memory leak when assignment in if condition #9426

p5pRT opened this issue Jul 21, 2008 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 21, 2008

Migrated from rt.perl.org#57174 (status was 'open')

Searchable as RT57174$

@p5pRT
Copy link
Author

p5pRT commented Jul 21, 2008

From Thushan.Abeysekera@computershare.com

Category​: core

Severity​: medium

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.

Thanks,

Thushan Abeysekera

Programmer Analyst

Computershare

******************************************************************************
Please visit the following website to read the Computershare legal notice​: http​://www.computershare.com/disclaimer/americas/en
Veuillez visiter le site Web suivant afin de prendre connaissance de l'avis juridique de Computershare​: http​://www.computershare.com/disclaimer/americas/fr

******************************************************************************

@p5pRT
Copy link
Author

p5pRT commented Jul 21, 2008

From Thushan.Abeysekera@computershare.com

Created by thushan.abeysekera@computershare.com

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.

Script 1 (This has the memory leak)​:

use strict;
test1();

sub test1 {
  my $v=0;
  if ($v = get_true()) {
  goto &test1;
  }
}

sub get_true {
  return 1;
}

Script 2 (This runs without a problem)​:

use strict;
test1();

sub test1 {
  my $v=0;
  $v = get_true();
  if ($v) {
  goto &test1;
  }
}

sub get_true {
  return 1;
}

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.

Perl Info
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.8.6:

Configured by ActiveState at Mon Dec 13 09:51:32 2004.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl586\lib\CORE"  -machine:x86'
    libpth=\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl586\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    21540 Fix backward-compatibility issues in if.pm
    23565 Wrong MANIFEST.SKIP

---
@INC for perl v5.8.6:
    c:/Perl586/lib
    c:/Perl586/site/lib
    .

---
Environment for perl v5.8.6:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=c:\perl586\bin;C:\Perl582\bin\;C:\Perl\bin;C:\PROGRA~1\ESWM\CLIENT~1\BIN;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\UltraEdit;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;R:\Resource\GPD\Scripts\Canada;R:\Resource\GPD\Scripts\ver1.40;R:\Resource\GPD\Scripts\Ver1.4;R:\Resource\GPD\Scripts\ver1.40;R:\Resource\bin;C:\Perl586\bin\;C:\Program Files\ATI Technologies\ATI Control Panel
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2008

From p5p@perl.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

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2008

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2008

From @iabyn

Leak still present in bleed@​35059, Dec 2008.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants