develooper Front page | perl.perl5.porters | Postings from April 2017

[perl #131219] memory leak in 5.24.1, regression

Thread Next
Gleb Smirnoff
April 28, 2017 02:40
[perl #131219] memory leak in 5.24.1, regression
Message ID:
# New Ticket Created by  Gleb Smirnoff 
# Please include the string:  [perl #131219]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.40 running under perl 5.24.1.

[Please describe your issue here]

There is a memory leak regression in perl 5.24.1, not present in
perl 5.22.3.  We managed to repropuce it in a small cyclic program
that uses Net::SNMP module.  Note, that problem doesn't belong to
the module, it is in the core.  When script is run with perl 5.24,
the perl process memory quickly grows.  When script is run with
perl 5.22 the perl process memory is constant.  The same Net::SNMP
module is used in both scenarios.

The script to reproduce:

use strict;
use warnings;

use constant OID_IFx_base => '';
use constant OID_IFx => {
    OID_IFx_base.".1.1"  => 'IFace',
    OID_IFx_base.".1.6"  => 'HCInOctets',
    OID_IFx_base.".1.10" => 'HCOutOctets',
    OID_IFx_base.".1.15" => 'HighSpeed',

use Net::SNMP qw(:snmp);

my $done = 0;
map {
        $SIG{$_} = sub { $done++ };
} qw (INT QUIT HUP);

printf("%s\n", $$);

while (! $done)
    my $oid_table = OID_IFx;
    my @oid_keys = oid_lex_sort(keys %$oid_table);
    my $table = [ ];
    my $toid;
    my $result;
    my ($session, $error) = Net::SNMP->session(
        -hostname    => '',
        -community   => 'public',
        -timeout     => 5, # seconds
        -retries     => 3,
        -nonblocking => 0,
        -translate   => [-octetstring => 0],
        -version     => 'snmpv2c',
    die sprintf("ERROR: %s\n", $error) unless defined $session;

    while (($toid = shift @oid_keys)) {
        $result = $session->get_table(-baseoid => $toid,
                                      -maxrepetitions => 1,);
        defined $result or die sprintf("ERROR: %s\n", $session->error());


    select(undef, undef, undef, 0.01);

[Please do not change anything below this line]
Site configuration information for perl 5.24.1:

Configured by perl at Sat Jan 14 20:05:52 UTC 2017.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration:
    osname=freebsd, osvers=12.0-current, archname=amd64-freebsd-thread-multi
    uname='freebsd head-amd64-default-job-02 12.0-current freebsd 12.0-current r316946 amd64 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.24/mach -Dprivlib=/usr/local/lib/perl5/5.24 -Dman3dir=/usr/local/lib/perl5/5.24/perl/man/man3 -Dman1dir=/usr/local/lib/perl5/5.24/perl/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.24 -Dsitelib=/usr/local/lib/perl5/site_perl -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dusenm=n -Dcc=cc -Duseshrplib -Dinc_version_list=none -Dcf_by=perl -Dcf_time=Sat Jan 14 20:05:52 UTC 2017 -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5.24/work/perl-5.24.1 -L/usr/local/lib/perl5/5.24/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5.24/work/perl-5.24.1:N-L/usr/local/lib/perl5/5.24/mach/CORE:N-lperl) -Wl,-soname,$(LIBPERL:R) -Doptimize=-O2 -pipe  -fstack-protector -fno-strict-aliasing -Dusedtrace -Ui_g
 dbm -Dusemultiplicity=y -Duse64bitint -Dusethreads=y -Dusemymalloc=n'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2',
    optimize='-O2 -pipe -fstack-protector -fno-strict-aliasing',
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='4.2.1 Compatible FreeBSD Clang 4.0.0 (tags/RELEASE_400/final 297347)', 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 ='-lpthread -Wl,-E  -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /usr/bin/../lib/clang/4.0.0/lib /usr/lib
    libs=-lpthread -lm -lcrypt -lutil
    perllibs=-lpthread -lm -lcrypt -lutil
    libc=, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.24/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib/perl5/5.24/mach/CORE -lperl -L/usr/local/lib -fstack-protector-strong'

@INC for perl 5.24.1:

Environment for perl 5.24.1:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About