Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.99k stars 559 forks source link

Severe memory leak #7172

Closed p5pRT closed 16 years ago

p5pRT commented 20 years ago

Migrated from rt.perl.org#27627 (status was 'rejected')

Searchable as RT27627$

p5pRT commented 20 years ago

From zatlas1@yahoo.com

Created by zatlas1@yahoo.com

The folowing code runs fine in activestate perl 5.6.1.635 but has a severe memory leak in 5.8.3.809. I had to uninstall that version and go back to 5.6.1 on my other machine. I've tried to send a bug report like this but I believe it did not go through\, so I am sending again

-> mycode​: # Usage​: findTableRef parm_file input_dir output_file # Parm file description​: # tttttttt # where # - ttttttttttt is a text pattern = object name. # # The programs allows virtually all legitimate Perl patterns as text # pattern

use strict; use File​::Find; use Cwd; our $fileP=$ARGV[0]; our $fileI=$ARGV[1]; our $fileO=$ARGV[2];

open (PARM\,"\< $fileP") or die "Can't open file $fileP : $!\r\n"; our @​regexes=(); our @​opcodes =(); our $regex = " "; while (\) {   chomp;   my $inpat = $_ ;   push @​regexes\, qr/\b$inpat\b/i; } close (PARM); our $j = $#regexes; open (OUT\,"> $fileO") or die "Can't open output file $fileO : $!\r\n"; print OUT "\"location\"\\,\"source_name\"\\,\"OWNER\"\\,\"OBJECT_NAME\"\\,\"environment\"\n"; find(\&edits\, $fileI); close (OUT);

sub edits () { return unless -f; my $file = $_; return if $file =~ /^\.\.?$/; return if $file =~ /\.zip$/i; return if $file =~ /\.xls$/i; return if $file =~ /\.csv$/i; return if $file =~ /\STARS_PD/; return if $file =~ /atls_.am\.txt/; return if $file =~ /atls_.nz\.txt/; return if $file =~ /\.doc$/i; return if $file =~ /\.exe$/i; return if $file =~ /employee_atlas\.txt/; return if $file =~ /AtlasWeb\.ear/i; return if $file =~ /AtlasWeb.war\~/i;

return if !open (SOURCE\, $file); my $pathname = getcwd; return if $pathname =~ m#/OLD/|/OLD$|/BAK/|/BAK$|/UNUSED/|/UNUSED$|/BK/|/BK$/|/WIN/|/WIN$#i; print "$pathname/$file\n"; #while (\) #{ my $lines = join ""\,(\); #$lines = uc $lines; #$file = uc $file; if ($file =~ /SQL/i) {   $lines =~ s#/\*.*?\*/##sg;   $lines =~ s/--.*?$//gm; } elsif ($file =~ /JAVA|BEAN|CLASS/i) {   $lines =~ s#/\*.*?\*/##sg;   $lines =~ s/\/\/.*?$//gm; } elsif ($file =~ /JSP|ASP/i) {   $lines =~ s/\<!--.*?-->//sg; }

my $owner = ""; my $ref =""; my $refenv = "";   foreach (@​regexes)   {   my $pat = $_;   my $flag = 0;   if ($lines =~ /^(.*(\bATLSD\b)\.($pat).*)$/mi)   {   $refenv = $1;   $owner = $2;   $ref =$3;   $flag = 1;   $refenv =~ s/(.)\"(.)/$1\`$2/g;   $refenv =~ s/(.)\"(.)/$1\`$2/g;   $refenv =~ s/(.)\"$/$1\`/g;   print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ;   }   if ($lines =~ /^(.*(\bATLSO\b)\.($pat).*)$/mi)   {   $refenv = $1;   $owner = $2;   $ref =$3;   $flag = 1;   $refenv =~ s/(.)\"(.)/$1\`$2/g;   $refenv =~ s/(.)\"(.)/$1\`$2/g;   $refenv =~ s/(.)\"$/$1\`/g;   print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ;   }   if ($flag == 0)   { # if ($lines =~ /^(.*(\b\w+?\b)\.($pat).*)$/mi) # { # $refenv = $1; # $owner = $2; # $ref =$3; # $flag = 1; # $refenv =~ s/(.)\"(.)/$1\`$2/g; # $refenv =~ s/(.)\"(.)/$1\`$2/g; # $refenv =~ s/(.)\"$/$1\`/g; # print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ; # } # elsif ($lines =~ /^(.*($pat).*)$/mi)   if ($lines =~ /^(.*($pat).*)$/mi)   {   $refenv = $1;   $owner = "";   $ref =$2; # $flag = 1;   $refenv =~ s/(.)\"(.)/$1\`$2/g;   $refenv =~ s/(.)\"(.)/$1\`$2/g;   $refenv =~ s/(.)\"$/$1\`/g;   print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ;   }   }   } close (SOURCE); undef $lines; }

\<-\<\<\< end of my code

Perl Info ``` Flags: category=core severity=high Site configuration information for perl v5.8.3: Configured by ActiveState at Tue Feb 3 00:28:38 2004. Summary of my perl5 (revision 5 version 8 subversion 3) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef 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:\Perl\lib\CORE" -machine:x86' libpth=C:\PROGRA~1\MICROS~3\VC98\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 wsock32.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 wsock32.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:\Perl\lib\CORE" -machine:x86' Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY 22218 Remove the caveat about detached threads crashing on Windows 22201 Avoid threads+win32 crash by freeing Perl interpreter slightly later 22169 Display 'out of memeory' errors using low-level I/O 22159 Upgrade to Time::Hires 1.55 22120 Make 'Configure -Dcf_by=...' work 22051 Upgrade to Time::HiRes 1.54 21540 Fix backward-compatibility issues in if.pm @INC for perl v5.8.3: C:/Perl/lib C:/Perl/site/lib . Environment for perl v5.8.3: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\Tcl\bin;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program files\PC-Doctor for Windows XP\WINDSAPI PERL_BADLANG (unset) SHELL (unset) __________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam http://mail.yahoo.com ```
p5pRT commented 20 years ago

From @iabyn

On Sun\, Mar 14\, 2004 at 05​:19​:42AM -0000\, Ze'ev Atlas (via RT) wrote​:

The folowing code runs fine in activestate perl 5.6.1.635 but has a severe memory leak in 5.8.3.809. I had to uninstall that version and go back to 5.6.1 on my other machine.

Thanks for the report; however\, you have not given us enough information to reproduce the bug. Your code relies on the existence of a a parm_file and a directory structure; would it be possible to proviide the file\, and details of the directory structure\, (possibly by placing a tar or zip file of the directory on a web server somewhere)

Also\, and very importantly\, would it be possible for you to reduce your code to the barest minimum that still exhibits the leak. For example is it the find() that creates the leak\, or all the code executed for each file?

Dave.

I've tried to send a bug report like this but I believe it did not go through\, so I am sending again

-> mycode​: # Usage​: findTableRef parm_file input_dir output_file # Parm file description​: # tttttttt # where # - ttttttttttt is a text pattern = object name. # # The programs allows virtually all legitimate Perl patterns as text # pattern

use strict; use File​::Find; use Cwd; our $fileP=$ARGV[0]; our $fileI=$ARGV[1]; our $fileO=$ARGV[2];

open (PARM\,"\< $fileP") or die "Can't open file $fileP : $!\r\n"; our @​regexes=(); our @​opcodes =(); our $regex = " "; while (\) { chomp; my $inpat = $_ ; push @​regexes\, qr/\b$inpat\b/i; } close (PARM); our $j = $#regexes; open (OUT\,"> $fileO") or die "Can't open output file $fileO : $!\r\n"; print OUT "\"location\"\\,\"source_name\"\\,\"OWNER\"\\,\"OBJECT_NAME\"\\,\"environment\"\n"; find(\&edits\, $fileI); close (OUT);

sub edits () { return unless -f; my $file = $_; return if $file =~ /^\.\.?$/; return if $file =~ /\.zip$/i; return if $file =~ /\.xls$/i; return if $file =~ /\.csv$/i; return if $file =~ /\STARS_PD/; return if $file =~ /atls_.am\.txt/; return if $file =~ /atls_.nz\.txt/; return if $file =~ /\.doc$/i; return if $file =~ /\.exe$/i; return if $file =~ /employee_atlas\.txt/; return if $file =~ /AtlasWeb\.ear/i; return if $file =~ /AtlasWeb.war\~/i;

return if !open (SOURCE\, $file); my $pathname = getcwd; return if $pathname =~ m#/OLD/|/OLD$|/BAK/|/BAK$|/UNUSED/|/UNUSED$|/BK/|/BK$/|/WIN/|/WIN$#i; print "$pathname/$file\n"; #while (\) #{ my $lines = join ""\,(\); #$lines = uc $lines; #$file = uc $file; if ($file =~ /SQL/i) { $lines =~ s#/\*.*?\*/##sg; $lines =~ s/--.*?$//gm; } elsif ($file =~ /JAVA|BEAN|CLASS/i) { $lines =~ s#/\*.*?\*/##sg; $lines =~ s/\/\/.*?$//gm; } elsif ($file =~ /JSP|ASP/i) { $lines =~ s/\<!--.*?-->//sg; }

my $owner = ""; my $ref =""; my $refenv = ""; foreach (@​regexes) { my $pat = $_; my $flag = 0; if ($lines =~ /^(.*(\bATLSD\b)\.($pat).*)$/mi) { $refenv = $1; $owner = $2; $ref =$3; $flag = 1; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"$/$1\`/g; print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ; } if ($lines =~ /^(.*(\bATLSO\b)\.($pat).*)$/mi) { $refenv = $1; $owner = $2; $ref =$3; $flag = 1; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"$/$1\`/g; print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ; } if ($flag == 0) { # if ($lines =~ /^(.*(\b\w+?\b)\.($pat).*)$/mi) # { # $refenv = $1; # $owner = $2; # $ref =$3; # $flag = 1; # $refenv =~ s/(.)\"(.)/$1\`$2/g; # $refenv =~ s/(.)\"(.)/$1\`$2/g; # $refenv =~ s/(.)\"$/$1\`/g; # print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ; # } # elsif ($lines =~ /^(.*($pat).*)$/mi) if ($lines =~ /^(.*($pat).*)$/mi) { $refenv = $1; $owner = ""; $ref =$2; # $flag = 1; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"$/$1\`/g; print OUT "\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n" ; } } } close (SOURCE); undef $lines; }

\<-\<\<\< end of my code

[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags​: category=core severity=high --- Site configuration information for perl v5.8.3​:

Configured by ActiveState at Tue Feb 3 00​:28​:38 2004.

Summary of my perl5 (revision 5 version 8 subversion 3) configuration​: Platform​: osname=MSWin32\, osvers=4.0\, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended\, useposix=true\, d_sigaction=undef usethreads=undef 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​:\Perl\lib\CORE" -machine​:x86' libpth=C​:\PROGRA~1\MICROS~3\VC98\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 wsock32.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 wsock32.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​:\Perl\lib\CORE" -machine​:x86'

Locally applied patches​: ACTIVEPERL_LOCAL_PATCHES_ENTRY 22218 Remove the caveat about detached threads crashing on Windows 22201 Avoid threads+win32 crash by freeing Perl interpreter slightly later 22169 Display 'out of memeory' errors using low-level I/O 22159 Upgrade to Time​::Hires 1.55 22120 Make 'Configure -Dcf_by=...' work 22051 Upgrade to Time​::HiRes 1.54 21540 Fix backward-compatibility issues in if.pm

--- @​INC for perl v5.8.3​: C​:/Perl/lib C​:/Perl/site/lib .

--- Environment for perl v5.8.3​: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset)

PATH=C​:\Tcl\bin;C​:\Perl\bin\;C​:\WINDOWS\system32;C​:\WINDOWS;C​:\WINDOWS\System32\Wbem;C​:\Program files\PC-Doctor for Windows XP\WINDSAPI PERL_BADLANG (unset) SHELL (unset)

__________________________________ Do you Yahoo!? Yahoo! Mail - More reliable\, more storage\, less spam http​://mail.yahoo.com

-- Lady Nancy Astor​: If you were my husband\, I would flavour your coffee with poison. Churchill​: Madam - if I were your husband\, I would drink it.

p5pRT commented 20 years ago

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

p5pRT commented 20 years ago

From zatlas1@yahoo.com

Hi I will try to provide it in the next 3 days Thanks for the response ZA --- Dave Mitchell via RT \perlbug\-followup@&#8203;perl\.org wrote​:

On Sun\, Mar 14\, 2004 at 05​:19​:42AM -0000\, Ze'ev Atlas (via RT) wrote​:

The folowing code runs fine in activestate perl 5.6.1.635 but has a severe memory leak in 5.8.3.809. I had to uninstall that version and go back to 5.6.1 on my other machine.

Thanks for the report; however\, you have not given us enough information to reproduce the bug. Your code relies on the existence of a a parm_file and a directory structure; would it be possible to proviide the file\, and details of the directory structure\, (possibly by placing a tar or zip file of the directory on a web server somewhere)

Also\, and very importantly\, would it be possible for you to reduce your code to the barest minimum that still exhibits the leak. For example is it the find() that creates the leak\, or all the code executed for each file?

Dave.

I've tried to send a bug report like this but I believe it did not go through\, so I am sending again

-> mycode​: # Usage​: findTableRef parm_file input_dir output_file # Parm file description​: # tttttttt # where # - ttttttttttt is a text pattern = object name. # # The programs allows virtually all legitimate Perl patterns as text # pattern

use strict; use File​::Find; use Cwd; our $fileP=$ARGV[0]; our $fileI=$ARGV[1]; our $fileO=$ARGV[2];

open (PARM\,"\< $fileP") or die "Can't open file $fileP : $!\r\n"; our @​regexes=(); our @​opcodes =(); our $regex = " "; while (\) { chomp; my $inpat = $_ ; push @​regexes\, qr/\b$inpat\b/i; } close (PARM); our $j = $#regexes; open (OUT\,"> $fileO") or die "Can't open output file $fileO : $!\r\n"; print OUT

"\"location\"\\,\"source_name\"\\,\"OWNER\"\\,\"OBJECT_NAME\"\\,\"environment\"\n";

find(\&edits\, $fileI); close (OUT);

sub edits () { return unless -f; my $file = $_; return if $file =~ /^\.\.?$/; return if $file =~ /\.zip$/i; return if $file =~ /\.xls$/i; return if $file =~ /\.csv$/i; return if $file =~ /\STARS_PD/; return if $file =~ /atls_.am\.txt/; return if $file =~ /atls_.nz\.txt/; return if $file =~ /\.doc$/i; return if $file =~ /\.exe$/i; return if $file =~ /employee_atlas\.txt/; return if $file =~ /AtlasWeb\.ear/i; return if $file =~ /AtlasWeb.war\~/i;

return if !open (SOURCE\, $file); my $pathname = getcwd; return if $pathname =~

m#/OLD/|/OLD$|/BAK/|/BAK$|/UNUSED/|/UNUSED$|/BK/|/BK$/|/WIN/|/WIN$#i;

print "$pathname/$file\n"; #while (\) #{ my $lines = join ""\,(\); #$lines = uc $lines; #$file = uc $file; if ($file =~ /SQL/i) { $lines =~ s#/\*.*?\*/##sg; $lines =~ s/--.*?$//gm; } elsif ($file =~ /JAVA|BEAN|CLASS/i) { $lines =~ s#/\*.*?\*/##sg; $lines =~ s/\/\/.*?$//gm; } elsif ($file =~ /JSP|ASP/i) { $lines =~ s/\<!--.*?-->//sg; }

my $owner = ""; my $ref =""; my $refenv = ""; foreach (@​regexes) { my $pat = $_; my $flag = 0; if ($lines =~ /^(.*(\bATLSD\b)\.($pat).*)$/mi) { $refenv = $1; $owner = $2; $ref =$3; $flag = 1; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"$/$1\`/g; print OUT

"\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n"

; } if ($lines =~ /^(.*(\bATLSO\b)\.($pat).*)$/mi) { $refenv = $1; $owner = $2; $ref =$3; $flag = 1; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"$/$1\`/g; print OUT

"\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n"

; } if ($flag == 0) { # if ($lines =~ /^(.*(\b\w+?\b)\.($pat).*)$/mi) # { # $refenv = $1; # $owner = $2; # $ref =$3; # $flag = 1; # $refenv =~ s/(.)\"(.)/$1\`$2/g; # $refenv =~ s/(.)\"(.)/$1\`$2/g; # $refenv =~ s/(.)\"$/$1\`/g; # print OUT

"\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n"

; # } # elsif ($lines =~ /^(.*($pat).*)$/mi) if ($lines =~ /^(.*($pat).*)$/mi) { $refenv = $1; $owner = ""; $ref =$2; # $flag = 1; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"(.)/$1\`$2/g; $refenv =~ s/(.)\"$/$1\`/g; print OUT

"\"$pathname\"\\,\"$file\"\\,\"$owner\"\\,\"$ref\"\\,\"$refenv\"\n"

; } } }

=== message truncated ===

__________________________________ Do you Yahoo!? Yahoo! Mail - More reliable\, more storage\, less spam http​://mail.yahoo.com

p5pRT commented 16 years ago

p5p@spam.wizbit.be - Status changed from 'open' to 'rejected'