[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[perl #59268] PerlIO::via leaks memory at a high rate



# New Ticket Created by  Marc Lehmann 
# Please include the string:  [perl #59268]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59268 >



This is a bug report for perl from pcg@goof.com,
generated with the help of perlbug 1.36 running under perl 5.10.0.


-----------------------------------------------------------------
[Please enter your report here]

The following test program leaks memory at a high rate (every write):

   while () {
      open my $fh, ">:via(bla)", \my $buf or die;
      print $fh "x";
   }  

   package PerlIO::via::bla;

   sub PUSHED {
      __PACAKGE__
   }

   sub WRITE {
      (print {$_[2]} $_[1]) ? length $_[1] : -1
   }  

An mtrace of a program running the loop some 400k times shows these leaks
as main causes, but there are many smaller leaks in via.so:

   [18065877 bytes in 403594 blocks, 1st. block is 45 bytes at 0x15c54a50] 
      0x1da54cb2 libktrace.so
      0x0045d085 util.c:95(Perl_safesysmalloc)
      0x0046dc1d hv.c:2418(S_share_hek_flags)
      0x0046f5da hv.c:766(Perl_hv_common)
      0x0046fe2c hv.c:323(Perl_hv_common_key_len)
      0x00541437 gv.c:1065(Perl_gv_fetchpvn_flags)
      0x1fbe2c95 via.so(PerlIOVia_method+0x345)
      0x1fbe30e5 via.so(PerlIOVia_write+0x65)
      0x004e2fed doio.c:1247(Perl_do_print)
      0x00485f6f pp_hot.c:778(Perl_pp_print)
      0x0047d27e run.c:38(Perl_runops_standard)
      0x0047975b perl.c:2384(S_run_body)
      0x0041f574 perlmain.c:113(main)
      0x1e6ac1a6 libc.so.6(__libc_start_main+0xe6)
   [9726720 bytes in 2384 blocks, 1st. block is 4080 bytes at 0x03da8e70] 
      0x1da54cb2 libktrace.so
      0x0045d085 util.c:95(Perl_safesysmalloc)
      0x00488718 sv.c:693(Perl_get_arena)
      0x0046f723 hv.c:44(S_more_he)
      0x0046fe2c hv.c:323(Perl_hv_common_key_len)
      0x00541437 gv.c:1065(Perl_gv_fetchpvn_flags)
      0x1fbe2c95 via.so(PerlIOVia_method+0x345)
      0x1fbe30e5 via.so(PerlIOVia_write+0x65)
      0x004e2fed doio.c:1247(Perl_do_print)
      0x00485f6f pp_hot.c:778(Perl_pp_print)
      0x0047d27e run.c:38(Perl_runops_standard)
      0x0047975b perl.c:2384(S_run_body)
      0x0041f574 perlmain.c:113(main)
      0x1e6ac1a6 libc.so.6(__libc_start_main+0xe6)

If I had to make a very quick guess, could it be that the
pseudo-filehandle creates via newGVgen creates a new _GEN_xxx symbol in
the ...::bla package that never ever gets freed?

Indeed, adding this line into the while loop:

   warn keys %PerlIO::via::bla::;

creates successively longer output lines. Could that mean that
newGVgen leaks?

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=medium
---
Site configuration information for perl 5.10.0:

Configured by Marc Lehmann at Sat Jan 19 07:46:38 CET 2008.

Summary of my perl5 (revision 5 version 10 subversion 0 patch 33007) configuration:
  Platform:
    osname=linux, osvers=2.6.23-1-amd64, archname=amd64-linux
    uname='linux cerebro 2.6.23-1-amd64 #1 smp fri dec 21 12:00:17 utc 2007 x86_64 gnulinux '
    config_args='-Duselargefiles -Dxxxxuse64bitint -Uuse64bitall -Dusemymalloc=n -Dcc=gcc -Dccflags=-DPERL_DONT_CREATE_GVSV_disabled -ggdb -Dcppflags=-DPERL_DONT_CREATE_GVSV_disabled -D_GNU_SOURCE -I/opt/include -Doptimize=-O6 -march=opteron -mtune=opteron -funroll-loops -fno-strict-aliasing -Dcccdlflags=-fPIC -Dldflags=-L/opt/perl/lib -L/opt/lib -Dlibs=-ldl -lm -lcrypt -Darchname=amd64-linux -Dprefix=/opt/perl -Dprivlib=/opt/perl/lib/perl5 -Darchlib=/opt/perl/lib/perl5 -Dvendorprefix=/opt/perl -Dvendorlib=/opt/perl/lib/perl5 -Dvendorarch=/opt/perl/lib/perl5 -Dsiteprefix=/opt/perl -Dsitelib=/opt/perl/lib/perl5 -Dsitearch=/opt/perl/lib/perl5 -Dsitebin=/opt/perl/bin -Dman1dir=/opt/perl/man/man1 -Dman3dir=/opt/perl/man/man3 -Dsiteman1dir=/opt/perl/man/man1 -Dsiteman3dir=/opt/perl/man/man3 -Dman1ext=1 -Dman3ext=3 -Dpager=/usr/bin/less -Uafs -Uusesfio -Uusenm -Uuseshrplib -Dd_dosuid -Dusethreads=undef -Duse5005threads=undef -Duseithreads=undef -Dusemultiplicity=undef -Demail=perl!
 -binary@plan9.de -Dcf_email=perl-binary@plan9.de -Dcf_by=Marc Lehmann -Dlocincpth=/opt/perl/include /opt/include -Dmyhostname=localhost -Dmultiarch=undef -Dbin=/opt/perl/bin -Dxxxusedevel -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_DONT_CREATE_GVSV_disabled -ggdb -fno-strict-aliasing -pipe -I/opt/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O6 -march=opteron -mtune=opteron -funroll-loops -fno-strict-aliasing',
    cppflags='-DPERL_DONT_CREATE_GVSV_disabled -D_GNU_SOURCE -I/opt/include -DPERL_DONT_CREATE_GVSV_disabled -ggdb -fno-strict-aliasing -pipe -I/opt/include'
    ccversion='', gccversion='4.2.3 20080102 (prerelease) (Debian 4.2.2-5)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-L/opt/perl/lib -L/opt/lib -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-ldl -lm -lcrypt
    perllibs=-ldl -lm -lcrypt
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O6 -march=opteron -mtune=opteron -funroll-loops -fno-strict-aliasing -L/opt/perl/lib -L/opt/lib -L/usr/local/lib'

Locally applied patches:
    MAINT

---
@INC for perl 5.10.0:
    /root/src/sex
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    .

---
Environment for perl 5.10.0:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=de_DE.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/root/s2:/root/s:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin:/usr/games:/usr/local/bin:/usr/local/sbin:/root/pserv:.
    PERL5LIB=/root/src/sex
    PERL5_CPANPLUS_CONFIG=/root/.cpanplus/config
    PERLDB_OPTS=ornaments=0
    PERL_ANYEVENT_EDNS0=1
    PERL_ANYEVENT_NET_TESTS=1
    PERL_ANYEVENT_PROTOCOLS=ipv4
    PERL_ANYEVENT_STRICT=1
    PERL_BADLANG (unset)
    PERL_UNICODE=0
    SHELL=/bin/bash


[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]