develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123922] v5.21.6-336-gfedf30e introduced a memory leak

Thread Next
From:
Tony Cook
Date:
February 25, 2015 04:41
Subject:
[perl #123922] v5.21.6-336-gfedf30e introduced a memory leak
Message ID:
rt-4.0.18-7324-1424839232-194.123922-75-0@perl.org
# New Ticket Created by  Tony Cook 
# Please include the string:  [perl #123922]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123922 >



This is a bug report for perl from tony@develop-help.com,
generated with the help of perlbug 1.40 running under perl 5.21.10.


-----------------------------------------------------------------
[Please describe your issue here]

fedf30e1c349130b23648c022f5f3cb4ad7928f3 (v5.21.6-336-gfedf30e)
introduced a memory leak when running the following code:

PERL_DESTRUCT_LEVEL=2 valgrind -q --leak-check=full ./perl -Ilib -Mwarnings -e0

In blead the reported leaks are:

==23030== 3,584 (512 direct, 3,072 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 26
==23030==    at 0x4C267BB: calloc (vg_replace_malloc.c:593)
==23030==    by 0x4203A6: Perl_Slab_Alloc (op.c:181)
==23030==    by 0x428C07: Perl_newSVOP (op.c:5807)
==23030==    by 0x46F985: S_force_word (toke.c:2034)
==23030==    by 0x485493: Perl_yylex (toke.c:7739)
==23030==    by 0x48D5DD: Perl_yyparse (perly.c:322)
==23030==    by 0x58B9A7: S_doeval (pp_ctl.c:3484)
==23030==    by 0x5929B9: Perl_pp_require (pp_ctl.c:4169)
==23030==    by 0x4D630A: Perl_runops_debug (dump.c:2231)
==23030==    by 0x44788E: Perl_call_sv (perl.c:2736)
==23030==    by 0x4482A1: Perl_call_list (perl.c:4842)
==23030==    by 0x42228A: S_process_special_blocks (op.c:8899)
==23030== 
==23030== 23,552 (1,024 direct, 22,528 indirect) bytes in 2 blocks are definitely lost in loss record 24 of 26
==23030==    at 0x4C267BB: calloc (vg_replace_malloc.c:593)
==23030==    by 0x4203A6: Perl_Slab_Alloc (op.c:181)
==23030==    by 0x42A193: Perl_newOP (op.c:4748)
==23030==    by 0x48E642: Perl_yyparse (perly.y:996)
==23030==    by 0x58B9A7: S_doeval (pp_ctl.c:3484)
==23030==    by 0x5929B9: Perl_pp_require (pp_ctl.c:4169)
==23030==    by 0x4D630A: Perl_runops_debug (dump.c:2231)
==23030==    by 0x44788E: Perl_call_sv (perl.c:2736)
==23030==    by 0x4482A1: Perl_call_list (perl.c:4842)
==23030==    by 0x42228A: S_process_special_blocks (op.c:8899)
==23030==    by 0x43BE95: Perl_newATTRSUB_x (op.c:8829)
==23030==    by 0x43EA7E: Perl_utilize (op.c:6052)
==23030== 
==23030== 48,640 (512 direct, 48,128 indirect) bytes in 1 blocks are definitely lost in loss record 25 of 26
==23030==    at 0x4C267BB: calloc (vg_replace_malloc.c:593)
==23030==    by 0x4203A6: Perl_Slab_Alloc (op.c:181)
==23030==    by 0x428C07: Perl_newSVOP (op.c:5807)
==23030==    by 0x46F985: S_force_word (toke.c:2034)
==23030==    by 0x485EFD: Perl_yylex (toke.c:7638)
==23030==    by 0x48D5DD: Perl_yyparse (perly.c:322)
==23030==    by 0x58B9A7: S_doeval (pp_ctl.c:3484)
==23030==    by 0x5929B9: Perl_pp_require (pp_ctl.c:4169)
==23030==    by 0x4D630A: Perl_runops_debug (dump.c:2231)
==23030==    by 0x44788E: Perl_call_sv (perl.c:2736)
==23030==    by 0x4482A1: Perl_call_list (perl.c:4842)
==23030==    by 0x42228A: S_process_special_blocks (op.c:8899)
==23030== 
==23030== 64,000 (1,536 direct, 62,464 indirect) bytes in 3 blocks are definitely lost in loss record 26 of 26
==23030==    at 0x4C267BB: calloc (vg_replace_malloc.c:593)
==23030==    by 0x4203A6: Perl_Slab_Alloc (op.c:181)
==23030==    by 0x42A193: Perl_newOP (op.c:4748)
==23030==    by 0x4722F9: Perl_yylex (toke.c:8243)
==23030==    by 0x48D5DD: Perl_yyparse (perly.c:322)
==23030==    by 0x58B9A7: S_doeval (pp_ctl.c:3484)
==23030==    by 0x5929B9: Perl_pp_require (pp_ctl.c:4169)
==23030==    by 0x4D630A: Perl_runops_debug (dump.c:2231)
==23030==    by 0x44788E: Perl_call_sv (perl.c:2736)
==23030==    by 0x4482A1: Perl_call_list (perl.c:4842)
==23030==    by 0x42228A: S_process_special_blocks (op.c:8899)
==23030==    by 0x43BE95: Perl_newATTRSUB_x (op.c:8829)
==23030== 

Simple code such as:

$ valgrind -q --leak-check=full ./perl -e '$x->[1][2]' 
==23620== 1,536 (512 direct, 1,024 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3
==23620==    at 0x4C267BB: calloc (vg_replace_malloc.c:593)
==23620==    by 0x4203A6: Perl_Slab_Alloc (op.c:181)
==23620==    by 0x428C07: Perl_newSVOP (op.c:5807)
==23620==    by 0x473AB6: Perl_yylex (toke.c:8308)
==23620==    by 0x48D5DD: Perl_yyparse (perly.c:322)
==23620==    by 0x44DEF5: S_parse_body (perl.c:2277)
==23620==    by 0x44F3AB: perl_parse (perl.c:1611)
==23620==    by 0x41B971: main (perlmain.c:114)
==23620== 

demonstrates one point of leakage, I haven't tried to duplicate the
others.

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

Configured by tony at Wed Feb 25 15:00:37 AEDT 2015.

Summary of my perl5 (revision 5 version 21 subversion 10) configuration:
  Commit id: 33593911f214382b592d05aa902655301915e666
  Platform:
    osname=linux, osvers=2.6.32-358.el6.x86_64, archname=x86_64-linux-thread-multi
    uname='linux dromedary-001.ams6.corp.booking.com 2.6.32-358.el6.x86_64 #1 smp fri feb 22 00:31:26 utc 2013 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Dprefix= -Uversiononly -Dusedevel -des -Dusethreads -DDEBUGGING=both'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-11)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.12'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        PERL_TRACK_MEMPOOL PERL_USE_DEVEL USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO
                        USE_PERL_ATOF USE_REENTRANT_API
  Built under linux
  Compiled at Feb 25 2015 05:29:40
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.21.10/x86_64-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.21.10
    /usr/local/lib/perl5/5.21.10/x86_64-linux-thread-multi
    /usr/local/lib/perl5/5.21.10
    /usr/local/lib/perl5/site_perl/5.12.3
    /usr/local/lib/perl5/site_perl/5.8.8
    /usr/local/lib/perl5/site_perl
    .


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About