List Info

Thread: Mem leak in IO::Handle




Mem leak in IO::Handle
user name
2007-10-23 09:04:12
# cat leaktest3.pl
use strict;
use warnings;

use IO::Handle;

my   $ufio;
open $ufio, "<", "xx.csv" and close
$ufio;
# valgrind --leak-check=full perl5.10.0 leaktest3.pl
==11033== Memcheck, a memory error detector.
==11033== Copyright (C) 2002-2007, and GNU GPL'd, by Julian
Seward et al.
==11033== Using LibVEX rev 1732, a library for dynamic
binary translation.
==11033== Copyright (C) 2004-2007, and GNU GPL'd, by
OpenWorks LLP.
==11033== Using valgrind-3.2.3, a dynamic binary
instrumentation framework.
==11033== Copyright (C) 2000-2007, and GNU GPL'd, by Julian
Seward et al.
==11033== For more details, rerun with: -v
==11033==
==11033== Invalid read of size 1
==11033==    at 0x4C23BA1: memmove (in
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==11033==    by 0x42BDDB: Perl_ck_require (in
/pro/bin/perl5.10.0)
==11033==    by 0x424D4F: Perl_newUNOP (in
/pro/bin/perl5.10.0)
==11033==    by 0x525030: Perl_yyparse (in
/pro/bin/perl5.10.0)
==11033==    by 0x4A77BB: S_doeval (in /pro/bin/perl5.10.0)
==11033==    by 0x4A9FE4: Perl_pp_require (in
/pro/bin/perl5.10.0)
==11033==    by 0x44D315: Perl_runops_debug (in
/pro/bin/perl5.10.0)
==11033==    by 0x46A979: Perl_call_sv (in
/pro/bin/perl5.10.0)
==11033==    by 0x46ADEB: Perl_call_list (in
/pro/bin/perl5.10.0)
==11033==    by 0x41F794: S_process_special_blocks (in
/pro/bin/perl5.10.0)
==11033==    by 0x42A05F: Perl_newATTRSUB (in
/pro/bin/perl5.10.0)
==11033==    by 0x428E8A: Perl_utilize (in
/pro/bin/perl5.10.0)
==11033==  Address 0x4131F48 is 0 bytes after a block of
size 16 alloc'd
==11033==    at 0x4C22AC6: malloc (in
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==11033==    by 0x456F62: Perl_safesysmalloc (in
/pro/bin/perl5.10.0)
==11033==    by 0x489397: Perl_sv_grow (in
/pro/bin/perl5.10.0)
==11033==    by 0x48B13F: Perl_sv_setpvn (in
/pro/bin/perl5.10.0)
==11033==    by 0x48B6AA: Perl_newSVpvn (in
/pro/bin/perl5.10.0)
==11033==    by 0x50E00D: S_newSV_maybe_utf8 (in
/pro/bin/perl5.10.0)
==11033==    by 0x512968: S_force_word (in
/pro/bin/perl5.10.0)
==11033==    by 0x518545: Perl_yylex (in
/pro/bin/perl5.10.0)
==11033==    by 0x5241CB: Perl_yyparse (in
/pro/bin/perl5.10.0)
==11033==    by 0x4A77BB: S_doeval (in /pro/bin/perl5.10.0)
==11033==    by 0x4A9FE4: Perl_pp_require (in
/pro/bin/perl5.10.0)
==11033==    by 0x44D315: Perl_runops_debug (in
/pro/bin/perl5.10.0)
==11033==
==11033== ERROR SUMMARY: 1 errors from 1 contexts
(suppressed: 2 from 1)
==11033== malloc/free: in use at exit: 603,565 bytes in
7,010 blocks.
==11033== malloc/free: 13,167 allocs, 6,157 frees, 1,044,841
bytes allocated.
==11033== For counts of detected errors, rerun with: -v
==11033== searching for pointers to 7,010 not-freed blocks.
==11033== checked 910,760 bytes.
==11033==
==11033== LEAK SUMMARY:
==11033==    definitely lost: 0 bytes in 0 blocks.
==11033==      possibly lost: 0 bytes in 0 blocks.
==11033==    still reachable: 603,565 bytes in 7,010
blocks.
==11033==         suppressed: 0 bytes in 0 blocks.
==11033== Reachable blocks (those to which a pointer was
found) are not shown.
==11033== To see them, rerun with: --leak-check=full
--show-reachable=yes
#

Comment out the 'use IO::Handle' and it is clean:

# valgrind --leak-check=full perl5.10.0 leaktest3.pl
==11192== Memcheck, a memory error detector.
==11192== Copyright (C) 2002-2007, and GNU GPL'd, by Julian
Seward et al.
==11192== Using LibVEX rev 1732, a library for dynamic
binary translation.
==11192== Copyright (C) 2004-2007, and GNU GPL'd, by
OpenWorks LLP.
==11192== Using valgrind-3.2.3, a dynamic binary
instrumentation framework.
==11192== Copyright (C) 2000-2007, and GNU GPL'd, by Julian
Seward et al.
==11192== For more details, rerun with: -v
==11192==
==11192==
==11192== ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 2 from 1)
==11192== malloc/free: in use at exit: 239,766 bytes in
2,287 blocks.
==11192== malloc/free: 5,437 allocs, 3,150 frees, 443,001
bytes allocated.
==11192== For counts of detected errors, rerun with: -v
==11192== searching for pointers to 2,287 not-freed blocks.
==11192== checked 554,504 bytes.
==11192==
==11192== LEAK SUMMARY:
==11192==    definitely lost: 0 bytes in 0 blocks.
==11192==      possibly lost: 0 bytes in 0 blocks.
==11192==    still reachable: 239,766 bytes in 2,287
blocks.
==11192==         suppressed: 0 bytes in 0 blocks.
==11192== Reachable blocks (those to which a pointer was
found) are not shown.
==11192== To see them, rerun with: --leak-check=full
--show-reachable=yes
#

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/
)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX
10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.     
 http://qa.perl.org
http://mirrors.de
velooper.com/hpux/            http://www.test-smoke.org
                        http
://www.goldmark.org/jeff/stupid-disclaimers/

Re: Mem leak in IO::Handle
user name
2007-10-23 09:58:35
On 23/10/2007, H.Merijn Brand <h.m.brandxs4all.nl> wrote:
> # cat leaktest3.pl
> use strict;
> use warnings;
>
> use IO::Handle;
>
> my   $ufio;
> open $ufio, "<", "xx.csv" and
close $ufio;
> # valgrind --leak-check=full perl5.10.0 leaktest3.pl

I think there is no memory leak, because you didn't set
PERL_DESTRUCT_LEVEL, and remainings objects aren't
destroyed.
Here's how I invoke valgrind for bleadperl:

    #!/bin/sh
    export PERL_DESTRUCT_LEVEL=2
    valgrind --suppressions=perl.supp --leak-check=yes
--leak-resolution=high --show-reachable=yes --num-callers=50
./perl
-MTestInit $*

However, the "invalid read" error is serious, and
new (I ran a valgrind
checks a few weeks ago). It happens with a bare "use
warnings".

Re: Mem leak in IO::Handle
user name
2007-10-24 04:33:12
On 23/10/2007, Rafael Garcia-Suarez <rgarciasuarezgmail.com> wrote:
> However, the "invalid read" error is serious,
and new (I ran a valgrind
> checks a few weeks ago). It happens with a bare
"use warnings".

Now fixed by #32183.

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )