Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.24.1 - Memory leak in regexp #15746

Closed
p5pRT opened this issue Dec 4, 2016 · 17 comments
Labels

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Dec 4, 2016

Migrated from rt.perl.org#130254 (status was 'resolved')

Searchable as RT130254$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From bitcard-120630@kirpa.com

Huge memory leak in case not very clean regular expression used within cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have this problem.

Please see below leak.pl, leak-report.sh, 20161204020211_leak_report.txt and perlbug -d
output.

Best regards,
Alexander Kirpa
-- cat leak.pl
use strict;
use warnings FATAL => 'all';

my $v=q{(\b)([a ])(?​:13[;]12)3213(\b)};
#my $v=q{(\b)([a ])(?​:13 12)3213(\b)};

my $v2=q{"$1$2aaaa$3"};

for (1..5)
{
my $t=$_;
my $v1 = $v;
if ($t % 2) { $v1 .= q{ }}
#no warnings;
$t =~ s{$v1}{$v2}gee;
#use warnings FATAL => 'all';
}
--
-- cat leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
perl -MTest​::LeakTrace​::Script=-verbose leak.pl 2> $t'_leak_report.txt'
--
-- cat 20161204020211_leak_report.txt
leaked SCALAR(0x80203d498) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb70) at 0x80203d498
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209ffd8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3bb8) at 0x80209ffd8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2c40
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x802029230) at 0x80209f570
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked ARRAY(0x80209ffa8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f0f0) at 0x80209ffa8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2b40
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bbe0) at 0x80209ff30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x80209ff30) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bbe0) at 0x80209ff30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x80209fe40) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bc70) at 0x80209fe40
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was found instead of
a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209fa80) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f8e8) at 0x80209fa80
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2be0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bb70) at 0x80203d498
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209f630) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f2d0) at 0x80209f630
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2aa0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bb60) at 0x80209f5a0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x80209f5a0) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb60) at 0x80209f5a0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was found instead of
a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x80209f570) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x802029230) at 0x80209f570
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked REGEXP(0x8020b4150) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = REGEXP(0x8020ae000) at 0x8020b4150
  REFCNT = 1
  FLAGS = ()
  PV = 0x802c99370 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
  CUR = 35
  COMPFLAGS = 0x0 ()
  EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
  ENGINE = 0x801001de8 (STANDARD)
  INTFLAGS = 0x0 ()
  NPARENS = 3
  LASTPAREN = 0
  LASTCLOSEPAREN = 0
  MINLEN = 11
  MINLENRET = 11
  GOFS = 0
  PRE_PREFIX = 4
  SUBLEN = 0
  SUBOFFSET = 0
  SUBCOFFSET = 0
  SUBBEG = 0x0
  MOTHER_RE = 0x0
  PAREN_NAMES = 0x0
  SUBSTRS = 0x802042a00
  PPRIVATE = 0x802c2d5c0
  OFFS = 0x802c64500
  QR_ANONCV = 0x0
  SAVED_COPY = 0x0
leaked ARRAY(0x8020f8258) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3be0) at 0x8020f8258
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2ca0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bc70) at 0x80209fe40
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was found instead
of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x8020f81f8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVMG(0x8020725d0) at 0x8020f81f8
  REFCNT = 1
  FLAGS = (SMG,POK,pPOK,VALID,EVALED)
  PV = 0x80203e500 "13;123213 "\0
  CUR = 10
  LEN = 16
  MAGIC = 0x802c99730
  MG_VIRTUAL = &PL_vtbl_regexp
  MG_TYPE = PERL_MAGIC_bm(B)
  MG_LEN = 256
  MG_PTR = 0x80204f600
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n"
  USEFUL = 100
--


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.24.1​:

Configured by perl at Thu Oct 13 00​:42​:09 EEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration​:

  Platform​:
  osname=freebsd, osvers=10.3-release, archname=amd64-freebsd-thread-multi
  uname='freebsd x8.homenet 10.3-release freebsd 10.3-release #1​: tue may 17 01​:32​:48
eest 2016 ank0@​x8-103.homenet​:usrobjusrsrcsysx8 amd64 '
  config_args='-sde -Dprefix=/usr/local -Dlibperl=libperl.so.5.24.1
-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=/usr/local/bin/clang38 -Duseshrplib
-Dinc_version_list=none -Dcf_by=perl -Dcf_email=perl@​FreeBSD.org -Dcf_time=Thu Oct 13
00​:42​:09 EEST 2016
-Alddlflags=-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4
-L/usr/local/lib/perl5/5.24/mach/CORE -lperl
-Dshrpldflags=$(LDDLFLAGS​:N-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4​:
N-L/usr/local/lib/perl5/5.24/mach/CORE​:N-lperl) -Wl,-soname,$(LIBPERL​:R) -Doptimize=-O3
-pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2 -march=native -fno-strict-aliasing
-march=corei7 -fstack-protector -Ui_gdbm -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
  Compiler​:
  cc='/usr/local/bin/clang38', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H
-fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include
-D_FORTIFY_SOURCE=2',
  optimize='-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2 -march=native
-fno-strict-aliasing -march=corei7 -fstack-protector',
  cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
  ccversion='', gccversion='4.2.1 Compatible Clang 3.8.1 (tags/RELEASE_381/final)',
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='/usr/local/bin/clang38', ldflags ='-lpthread -Wl,-E -fstack-protector-strong
-L/usr/local/lib'
  libpth=/usr/lib /usr/local/lib /usr/local/llvm38/bin/../lib/clang/3.8.1/lib /usr/lib
  libs=-lpthread -lm -lcrypt -lutil
  perllibs=-lpthread -lm -lcrypt -lutil
  libc=, so=so, useshrplib=true, libperl=libperl.so.5.24.1
  gnulibc_version=''
  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'

Locally applied patches​:
  RC4


@​INC for perl 5.24.1​:
  /usr/local/lib/perl5/site_perl/mach/5.24
  /usr/local/lib/perl5/site_perl
  /usr/local/lib/perl5/5.24/mach
  /usr/local/lib/perl5/5.24


Environment for perl 5.24.1​:
  HOME=/root
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/sbin​:/bin​:/usr/sbin​:/usr/bin​:/usr/games​:/usr/local/sbin​:/usr/local/bin​:/root/bin
  PERL_BADLANG (unset)
  SHELL=/bin/csh

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From bitcard-120630@kirpa.com

Sorry for unsuccessful content.
Please see clear text below​:


Huge memory leak in case not very clean regular expression used within cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have this problem.

Please see below leak.pl, leak-report.sh, 20161204020211_leak_report.txt and perlbug -d output.

Best regards,
Alexander Kirpa
-- cat leak.pl
use strict;
use warnings FATAL => 'all';

my $v=q{(\b)([a ])(?​:13[;]12)3213(\b)};
#my $v=q{(\b)([a ])(?​:13 12)3213(\b)};

my $v2=q{"$1$2aaaa$3"};

for (1..5)
{
my $t=$_;
my $v1 = $v;
if ($t % 2) { $v1 .= q{ }}
#no warnings;
$t =~ s{$v1}{$v2}gee;
#use warnings FATAL => 'all';
}
--
-- cat leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
perl -MTest​::LeakTrace​::Script=-verbose leak.pl 2> $t'_leak_report.txt'
--
-- cat 20161204020211_leak_report.txt
leaked SCALAR(0x80203d498) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb70) at 0x80203d498
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209ffd8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3bb8) at 0x80209ffd8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2c40
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x802029230) at 0x80209f570
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked ARRAY(0x80209ffa8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f0f0) at 0x80209ffa8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2b40
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bbe0) at 0x80209ff30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x80209ff30) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bbe0) at 0x80209ff30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x80209fe40) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bc70) at 0x80209fe40
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209fa80) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f8e8) at 0x80209fa80
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2be0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bb70) at 0x80203d498
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209f630) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f2d0) at 0x80209f630
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2aa0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bb60) at 0x80209f5a0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x80209f5a0) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb60) at 0x80209f5a0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x80209f570) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x802029230) at 0x80209f570
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked REGEXP(0x8020b4150) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = REGEXP(0x8020ae000) at 0x8020b4150
  REFCNT = 1
  FLAGS = ()
  PV = 0x802c99370 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
  CUR = 35
  COMPFLAGS = 0x0 ()
  EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
  ENGINE = 0x801001de8 (STANDARD)
  INTFLAGS = 0x0 ()
  NPARENS = 3
  LASTPAREN = 0
  LASTCLOSEPAREN = 0
  MINLEN = 11
  MINLENRET = 11
  GOFS = 0
  PRE_PREFIX = 4
  SUBLEN = 0
  SUBOFFSET = 0
  SUBCOFFSET = 0
  SUBBEG = 0x0
  MOTHER_RE = 0x0
  PAREN_NAMES = 0x0
  SUBSTRS = 0x802042a00
  PPRIVATE = 0x802c2d5c0
  OFFS = 0x802c64500
  QR_ANONCV = 0x0
  SAVED_COPY = 0x0
leaked ARRAY(0x8020f8258) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3be0) at 0x8020f8258
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2ca0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bc70) at 0x80209fe40
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x8020f81f8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVMG(0x8020725d0) at 0x8020f81f8
  REFCNT = 1
  FLAGS = (SMG,POK,pPOK,VALID,EVALED)
  PV = 0x80203e500 "13;123213 "\0
  CUR = 10
  LEN = 16
  MAGIC = 0x802c99730
  MG_VIRTUAL = &PL_vtbl_regexp
  MG_TYPE = PERL_MAGIC_bm(B)
  MG_LEN = 256
  MG_PTR = 0x80204f600 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  USEFUL = 100
--


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.24.1​:

Configured by perl at Thu Oct 13 00​:42​:09 EEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration​:

  Platform​:
  osname=freebsd, osvers=10.3-release, archname=amd64-freebsd-thread-multi
  uname='freebsd x8.homenet 10.3-release freebsd 10.3-release #1​: tue may 17 01​:32​:48 eest 2016 ank0@​x8-103.homenet​:usrobjusrsrcsysx8 amd64 '
  config_args='-sde -Dprefix=/usr/local -Dlibperl=libperl.so.5.24.1 -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=/usr/local/bin/clang38 -Duseshrplib -Dinc_version_list=none -Dcf_by=perl -Dcf_email=perl@​FreeBSD.org -Dcf_time=Thu Oct 13 00​:42​:09 EEST 2016 -Alddlflags=-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4 -L/usr/local/lib/perl5/5.24/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS​:N-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4​:N-L/usr/local/lib/perl5/5.24/mach/CORE​:N-lperl) -Wl,-soname,$(LIBPERL​:R) -Doptimize=-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2 -march=native -fno-strict-aliasing -march=corei7 -fstack-protector -Ui_gdbm -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
  Compiler​:
  cc='/usr/local/bin/clang38', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2',
  optimize='-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2 -march=native -fno-strict-aliasing -march=corei7 -fstack-protector',
  cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
  ccversion='', gccversion='4.2.1 Compatible Clang 3.8.1 (tags/RELEASE_381/final)', 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='/usr/local/bin/clang38', ldflags ='-lpthread -Wl,-E -fstack-protector-strong -L/usr/local/lib'
  libpth=/usr/lib /usr/local/lib /usr/local/llvm38/bin/../lib/clang/3.8.1/lib /usr/lib
  libs=-lpthread -lm -lcrypt -lutil
  perllibs=-lpthread -lm -lcrypt -lutil
  libc=, so=so, useshrplib=true, libperl=libperl.so.5.24.1
  gnulibc_version=''
  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'

Locally applied patches​:
  RC4


@​INC for perl 5.24.1​:
  /usr/local/lib/perl5/site_perl/mach/5.24
  /usr/local/lib/perl5/site_perl
  /usr/local/lib/perl5/5.24/mach
  /usr/local/lib/perl5/5.24


Environment for perl 5.24.1​:
  HOME=/root
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/sbin​:/bin​:/usr/sbin​:/usr/bin​:/usr/games​:/usr/local/sbin​:/usr/local/bin​:/root/bin
  PERL_BADLANG (unset)
  SHELL=/bin/csh
 


@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From [Unknown Contact. See original ticket]

Sorry for unsuccessful content.
Please see clear text below​:


Huge memory leak in case not very clean regular expression used within cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have this problem.

Please see below leak.pl, leak-report.sh, 20161204020211_leak_report.txt and perlbug -d output.

Best regards,
Alexander Kirpa
-- cat leak.pl
use strict;
use warnings FATAL => 'all';

my $v=q{(\b)([a ])(?​:13[;]12)3213(\b)};
#my $v=q{(\b)([a ])(?​:13 12)3213(\b)};

my $v2=q{"$1$2aaaa$3"};

for (1..5)
{
my $t=$_;
my $v1 = $v;
if ($t % 2) { $v1 .= q{ }}
#no warnings;
$t =~ s{$v1}{$v2}gee;
#use warnings FATAL => 'all';
}
--
-- cat leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
perl -MTest​::LeakTrace​::Script=-verbose leak.pl 2> $t'_leak_report.txt'
--
-- cat 20161204020211_leak_report.txt
leaked SCALAR(0x80203d498) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb70) at 0x80203d498
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209ffd8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3bb8) at 0x80209ffd8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2c40
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x802029230) at 0x80209f570
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked ARRAY(0x80209ffa8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f0f0) at 0x80209ffa8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2b40
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bbe0) at 0x80209ff30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x80209ff30) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bbe0) at 0x80209ff30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x80209fe40) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bc70) at 0x80209fe40
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209fa80) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f8e8) at 0x80209fa80
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2be0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bb70) at 0x80203d498
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x80209f630) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f2d0) at 0x80209f630
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2aa0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bb60) at 0x80209f5a0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x80209f5a0) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb60) at 0x80209f5a0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x80209f570) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PV(0x802029230) at 0x80209f570
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked REGEXP(0x8020b4150) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = REGEXP(0x8020ae000) at 0x8020b4150
  REFCNT = 1
  FLAGS = ()
  PV = 0x802c99370 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
  CUR = 35
  COMPFLAGS = 0x0 ()
  EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
  ENGINE = 0x801001de8 (STANDARD)
  INTFLAGS = 0x0 ()
  NPARENS = 3
  LASTPAREN = 0
  LASTCLOSEPAREN = 0
  MINLEN = 11
  MINLENRET = 11
  GOFS = 0
  PRE_PREFIX = 4
  SUBLEN = 0
  SUBOFFSET = 0
  SUBCOFFSET = 0
  SUBBEG = 0x0
  MOTHER_RE = 0x0
  PAREN_NAMES = 0x0
  SUBSTRS = 0x802042a00
  PPRIVATE = 0x802c2d5c0
  OFFS = 0x802c64500
  QR_ANONCV = 0x0
  SAVED_COPY = 0x0
leaked ARRAY(0x8020f8258) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3be0) at 0x8020f8258
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x802ce2ca0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x80201bc70) at 0x80209fe40
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x8020f81f8) from leak.pl line 15.
  14​:#no warnings;
  15​: $t =~ s{$v1}{$v2}gee;
  16​:#use warnings FATAL => 'all';
SV = PVMG(0x8020725d0) at 0x8020f81f8
  REFCNT = 1
  FLAGS = (SMG,POK,pPOK,VALID,EVALED)
  PV = 0x80203e500 "13;123213 "\0
  CUR = 10
  LEN = 16
  MAGIC = 0x802c99730
  MG_VIRTUAL = &PL_vtbl_regexp
  MG_TYPE = PERL_MAGIC_bm(B)
  MG_LEN = 256
  MG_PTR = 0x80204f600 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  USEFUL = 100
--


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.24.1​:

Configured by perl at Thu Oct 13 00​:42​:09 EEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration​:

  Platform​:
  osname=freebsd, osvers=10.3-release, archname=amd64-freebsd-thread-multi
  uname='freebsd x8.homenet 10.3-release freebsd 10.3-release #1​: tue may 17 01​:32​:48 eest 2016 ank0@​x8-103.homenet​:usrobjusrsrcsysx8 amd64 '
  config_args='-sde -Dprefix=/usr/local -Dlibperl=libperl.so.5.24.1 -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=/usr/local/bin/clang38 -Duseshrplib -Dinc_version_list=none -Dcf_by=perl -Dcf_email=perl@​FreeBSD.org -Dcf_time=Thu Oct 13 00​:42​:09 EEST 2016 -Alddlflags=-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4 -L/usr/local/lib/perl5/5.24/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS​:N-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4​:N-L/usr/local/lib/perl5/5.24/mach/CORE​:N-lperl) -Wl,-soname,$(LIBPERL​:R) -Doptimize=-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2 -march=native -fno-strict-aliasing -march=corei7 -fstack-protector -Ui_gdbm -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
  Compiler​:
  cc='/usr/local/bin/clang38', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2',
  optimize='-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2 -march=native -fno-strict-aliasing -march=corei7 -fstack-protector',
  cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
  ccversion='', gccversion='4.2.1 Compatible Clang 3.8.1 (tags/RELEASE_381/final)', 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='/usr/local/bin/clang38', ldflags ='-lpthread -Wl,-E -fstack-protector-strong -L/usr/local/lib'
  libpth=/usr/lib /usr/local/lib /usr/local/llvm38/bin/../lib/clang/3.8.1/lib /usr/lib
  libs=-lpthread -lm -lcrypt -lutil
  perllibs=-lpthread -lm -lcrypt -lutil
  libc=, so=so, useshrplib=true, libperl=libperl.so.5.24.1
  gnulibc_version=''
  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'

Locally applied patches​:
  RC4


@​INC for perl 5.24.1​:
  /usr/local/lib/perl5/site_perl/mach/5.24
  /usr/local/lib/perl5/site_perl
  /usr/local/lib/perl5/5.24/mach
  /usr/local/lib/perl5/5.24


Environment for perl 5.24.1​:
  HOME=/root
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/sbin​:/bin​:/usr/sbin​:/usr/bin​:/usr/games​:/usr/local/sbin​:/usr/local/bin​:/root/bin
  PERL_BADLANG (unset)
  SHELL=/bin/csh
 


@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From @jkeenan

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

Please see below leak.pl, leak-report.sh,
20161204020211_leak_report.txt and perlbug -d output.

Best regards,
Alexander Kirpa
-- cat leak.pl
use strict;
use warnings FATAL => 'all';

my $v=q{(\b)([a ])(?​:13[;]12)3213(\b)};
#my $v=q{(\b)([a ])(?​:13 12)3213(\b)};

my $v2=q{"$1$2aaaa$3"};

for (1..5)
{
my $t=$_;
my $v1 = $v;
if ($t % 2) { $v1 .= q{ }}
#no warnings;
$t =~ s{$v1}{$v2}gee;
#use warnings FATAL => 'all';
}
--
-- cat leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
perl -MTest​::LeakTrace​::Script=-verbose leak.pl 2>
$t'_leak_report.txt'
--
-- cat 20161204020211_leak_report.txt
leaked SCALAR(0x80203d498) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb70) at 0x80203d498
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked ARRAY(0x80209ffd8) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3bb8) at 0x80209ffd8
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2c40
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x802029230) at 0x80209f570
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked ARRAY(0x80209ffa8) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f0f0) at 0x80209ffa8
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2b40
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bbe0) at 0x80209ff30
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked SCALAR(0x80209ff30) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bbe0) at 0x80209ff30
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked SCALAR(0x80209fe40) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bc70) at 0x80209fe40
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked ARRAY(0x80209fa80) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f8e8) at 0x80209fa80
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2be0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bb70) at 0x80203d498
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked ARRAY(0x80209f630) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f2d0) at 0x80209f630
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2aa0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bb60) at 0x80209f5a0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked SCALAR(0x80209f5a0) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb60) at 0x80209f5a0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked SCALAR(0x80209f570) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x802029230) at 0x80209f570
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked REGEXP(0x8020b4150) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = REGEXP(0x8020ae000) at 0x8020b4150
REFCNT = 1
FLAGS = ()
PV = 0x802c99370 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
CUR = 35
COMPFLAGS = 0x0 ()
EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
ENGINE = 0x801001de8 (STANDARD)
INTFLAGS = 0x0 ()
NPARENS = 3
LASTPAREN = 0
LASTCLOSEPAREN = 0
MINLEN = 11
MINLENRET = 11
GOFS = 0
PRE_PREFIX = 4
SUBLEN = 0
SUBOFFSET = 0
SUBCOFFSET = 0
SUBBEG = 0x0
MOTHER_RE = 0x0
PAREN_NAMES = 0x0
SUBSTRS = 0x802042a00
PPRIVATE = 0x802c2d5c0
OFFS = 0x802c64500
QR_ANONCV = 0x0
SAVED_COPY = 0x0
leaked ARRAY(0x8020f8258) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3be0) at 0x8020f8258
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2ca0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bc70) at 0x80209fe40
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked SCALAR(0x8020f81f8) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVMG(0x8020725d0) at 0x8020f81f8
REFCNT = 1
FLAGS = (SMG,POK,pPOK,VALID,EVALED)
PV = 0x80203e500 "13;123213 "\0
CUR = 10
LEN = 16
MAGIC = 0x802c99730
MG_VIRTUAL = &PL_vtbl_regexp
MG_TYPE = PERL_MAGIC_bm(B)
MG_LEN = 256
MG_PTR = 0x80204f600
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
USEFUL = 100
--

I ran your program with both "warnings" ('no warnings in block commented out) and without ('no warnings uncommented).

I'm not very familiar with Test​::LeakTrace​::Script, but I note that when I uncommented 'no warnings' in the block, I did not eliminate *all* memory leaks. It appears that there remain a leaked SCALAR and a leaked REGEXP. Is that a concern?

I'll attach the two different leak reports. Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From @jkeenan

leaked SCALAR(0x11c2178) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PV(0x11c2ef0) at 0x11c2178
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11ed5b0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x11d7418) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PVAV(0x11c3df8) at 0x11d7418
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x11d06b0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x11c2e80) at 0x11d7370
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11e9c60 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x11d7370) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PV(0x11c2e80) at 0x11d7370
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11e9c60 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x11d72c8) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PV(0x11c2f80) at 0x11d72c8
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11e5840 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked ARRAY(0x11e1dc8) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PVAV(0x11c3c18) at 0x11e1dc8
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x120ba00
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x11c2f40) at 0x11e1d80
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11e9a30 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked ARRAY(0x11e1d98) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PVAV(0x11c4410) at 0x11e1d98
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x11d1d00
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x11c2ef0) at 0x11c2178
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11ed5b0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x11e1d80) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PV(0x11c2f40) at 0x11e1d80
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11e9a30 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked SCALAR(0x11e1d20) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PV(0x11c2f20) at 0x11e1d20
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x1591fb0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked ARRAY(0x1601550) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PVAV(0x15e8108) at 0x1601550
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x11e9ad0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x11c2f80) at 0x11d72c8
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x11e5840 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
  CUR = 149
  LEN = 152
leaked REGEXP(0x1601538) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = REGEXP(0x11e7a10) at 0x1601538
  REFCNT = 1
  FLAGS = ()
  PV = 0x11e9b00 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
  CUR = 35
  COMPFLAGS = 0x0 ()
  EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
  ENGINE = 0x572a80 (STANDARD)
  INTFLAGS = 0x0 ()
  NPARENS = 3
  LASTPAREN = 0
  LASTCLOSEPAREN = 0
  MINLEN = 11
  MINLENRET = 11
  GOFS = 0
  PRE_PREFIX = 4
  SUBLEN = 0
  SUBOFFSET = 0
  SUBCOFFSET = 0
  SUBBEG = 0x0
  MOTHER_RE = 0x0
  PAREN_NAMES = 0x0
  SUBSTRS = 0x11e59c0
  PPRIVATE = 0x11d05e0
  OFFS = 0x11f2f70
  QR_ANONCV = 0x0
  SAVED_COPY = 0x0
leaked ARRAY(0x1601520) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PVAV(0x15e8130) at 0x1601520
  REFCNT = 1
  FLAGS = ()
  ARRAY = 0x11e58e0
  FILL = 0
  MAX = 3
  ARYLEN = 0x0
  FLAGS = (REAL)
  Elt No. 0
  SV = PV(0x11c2f20) at 0x11e1d20
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x1591fb0 "Assuming NOT a POSIX class since a semi-colon was found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
  CUR = 150
  LEN = 152
leaked SCALAR(0x1601478) from leak.pl line 17.
  16​: #no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: #use warnings FATAL => 'all';
SV = PVMG(0x11e4280) at 0x1601478
  REFCNT = 1
  FLAGS = (SMG,POK,pPOK,VALID,EVALED)
  PV = 0x1592150 "13;123213 "\0
  CUR = 10
  LEN = 16
  MAGIC = 0x11db1a0
  MG_VIRTUAL = &PL_vtbl_regexp
  MG_TYPE = PERL_MAGIC_bm(B)
  MG_LEN = 256
  MG_PTR = 0x1592280 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  USEFUL = 100

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From @jkeenan

leaked SCALAR(0x23b7418) from leak.pl line 17.
  16​: no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: use warnings FATAL => 'all';
SV = PVMG(0x23c4280) at 0x23b7418
  REFCNT = 1
  FLAGS = (SMG,POK,pPOK,VALID,EVALED)
  PV = 0x23eb9a0 "13;123213 "\0
  CUR = 10
  LEN = 16
  MAGIC = 0x23b05e0
  MG_VIRTUAL = &PL_vtbl_regexp
  MG_TYPE = PERL_MAGIC_bm(B)
  MG_LEN = 256
  MG_PTR = 0x23c59c0 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  USEFUL = 100
leaked REGEXP(0x23b7370) from leak.pl line 17.
  16​: no warnings;
  17​: $t =~ s{$v1}{$v2}gee;
  18​: use warnings FATAL => 'all';
SV = REGEXP(0x23c7a10) at 0x23b7370
  REFCNT = 1
  FLAGS = ()
  PV = 0x23c5b00 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
  CUR = 35
  COMPFLAGS = 0x0 ()
  EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
  ENGINE = 0x572a80 (STANDARD)
  INTFLAGS = 0x0 ()
  NPARENS = 3
  LASTPAREN = 0
  LASTCLOSEPAREN = 0
  MINLEN = 11
  MINLENRET = 11
  GOFS = 0
  PRE_PREFIX = 4
  SUBLEN = 0
  SUBOFFSET = 0
  SUBCOFFSET = 0
  SUBBEG = 0x0
  MOTHER_RE = 0x0
  PAREN_NAMES = 0x0
  SUBSTRS = 0x23cd5b0
  PPRIVATE = 0x23c9c40
  OFFS = 0x23eb9c0
  QR_ANONCV = 0x0
  SAVED_COPY = 0x0

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

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

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 4, 2016

From @jkeenan

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

List​: Does anyone know how to use Porting/bisect.pl to identify the commit where the (additional) memory leakage occured?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 5, 2016

From @jkeenan

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

I built perl 5 blead and installed Test​::LeakReport against it.

#####
$ ./bin/perl -v | head -2 | tail -1
This is perl 5, version 25, subversion 8 (v5.25.8 (v5.25.7-50-g4f738c7)) built for x86_64-linux
#####
$ cat my-leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
BLEADPERL=/home/jkeenan/testing/blead/bin/perl
$BLEADPERL -MTest​::LeakTrace​::Script=-verbose leak.pl 2> $t'_leak_report.txt'
#####
sh my-leak-report.sh
#####

When I expected the leak report (attached), I did not see the long (12 leakages) leak report than you and I got at 5.24.0 -- only a short (2 leadages) report.

Is it possible that the problem has already been corrected?

Thank you very much.

Please see below leak.pl, leak-report.sh,
20161204020211_leak_report.txt and perlbug -d output.

Best regards,
Alexander Kirpa
-- cat leak.pl
use strict;
use warnings FATAL => 'all';

my $v=q{(\b)([a ])(?​:13[;]12)3213(\b)};
#my $v=q{(\b)([a ])(?​:13 12)3213(\b)};

my $v2=q{"$1$2aaaa$3"};

for (1..5)
{
my $t=$_;
my $v1 = $v;
if ($t % 2) { $v1 .= q{ }}
#no warnings;
$t =~ s{$v1}{$v2}gee;
#use warnings FATAL => 'all';
}
--
-- cat leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
perl -MTest​::LeakTrace​::Script=-verbose leak.pl 2>
$t'_leak_report.txt'
--
-- cat 20161204020211_leak_report.txt
leaked SCALAR(0x80203d498) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb70) at 0x80203d498
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked ARRAY(0x80209ffd8) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3bb8) at 0x80209ffd8
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2c40
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x802029230) at 0x80209f570
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked ARRAY(0x80209ffa8) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f0f0) at 0x80209ffa8
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2b40
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bbe0) at 0x80209ff30
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked SCALAR(0x80209ff30) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bbe0) at 0x80209ff30
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3a60 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked SCALAR(0x80209fe40) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bc70) at 0x80209fe40
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked ARRAY(0x80209fa80) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f8e8) at 0x80209fa80
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2be0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bb70) at 0x80203d498
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3b00 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked ARRAY(0x80209f630) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x80203f2d0) at 0x80209f630
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2aa0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bb60) at 0x80209f5a0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked SCALAR(0x80209f5a0) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x80201bb60) at 0x80209f5a0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d39c0 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked SCALAR(0x80209f570) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PV(0x802029230) at 0x80209f570
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3ba0 "Assuming NOT a POSIX class since a semi-colon was
found instead of a colon in regex; marked by <-- HERE in m/(\\b)([a
])(?​:13[; <-- HERE ]12)3213(\\b)/"\0
CUR = 149
LEN = 152
leaked REGEXP(0x8020b4150) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = REGEXP(0x8020ae000) at 0x8020b4150
REFCNT = 1
FLAGS = ()
PV = 0x802c99370 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
CUR = 35
COMPFLAGS = 0x0 ()
EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
ENGINE = 0x801001de8 (STANDARD)
INTFLAGS = 0x0 ()
NPARENS = 3
LASTPAREN = 0
LASTCLOSEPAREN = 0
MINLEN = 11
MINLENRET = 11
GOFS = 0
PRE_PREFIX = 4
SUBLEN = 0
SUBOFFSET = 0
SUBCOFFSET = 0
SUBBEG = 0x0
MOTHER_RE = 0x0
PAREN_NAMES = 0x0
SUBSTRS = 0x802042a00
PPRIVATE = 0x802c2d5c0
OFFS = 0x802c64500
QR_ANONCV = 0x0
SAVED_COPY = 0x0
leaked ARRAY(0x8020f8258) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVAV(0x802ce3be0) at 0x8020f8258
REFCNT = 1
FLAGS = ()
ARRAY = 0x802ce2ca0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = PV(0x80201bc70) at 0x80209fe40
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8022d3c40 "Assuming NOT a POSIX class since a semi-colon
was found instead of a colon in regex; marked by <-- HERE in
m/(\\b)([a ])(?​:13[; <-- HERE ]12)3213(\\b) /"\0
CUR = 150
LEN = 152
leaked SCALAR(0x8020f81f8) from leak.pl line 15.
14​:#no warnings;
15​: $t =~ s{$v1}{$v2}gee;
16​:#use warnings FATAL => 'all';
SV = PVMG(0x8020725d0) at 0x8020f81f8
REFCNT = 1
FLAGS = (SMG,POK,pPOK,VALID,EVALED)
PV = 0x80203e500 "13;123213 "\0
CUR = 10
LEN = 16
MAGIC = 0x802c99730
MG_VIRTUAL = &PL_vtbl_regexp
MG_TYPE = PERL_MAGIC_bm(B)
MG_LEN = 256
MG_PTR = 0x80204f600
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
USEFUL = 100
--

---
Flags​:
category=core
severity=low
---
Site configuration information for perl 5.24.1​:

Configured by perl at Thu Oct 13 00​:42​:09 EEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 1)
configuration​:

Platform​:
osname=freebsd, osvers=10.3-release, archname=amd64-freebsd-thread-
multi
uname='freebsd x8.homenet 10.3-release freebsd 10.3-release #1​: tue
may 17 01​:32​:48 eest 2016 ank0@​x8-103.homenet​:usrobjusrsrcsysx8 amd64
'
config_args='-sde -Dprefix=/usr/local -Dlibperl=libperl.so.5.24.1
-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=/usr/local/bin/clang38
-Duseshrplib -Dinc_version_list=none -Dcf_by=perl
-Dcf_email=perl@​FreeBSD.org -Dcf_time=Thu Oct 13 00​:42​:09 EEST 2016
-Alddlflags=-L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-
RC4 -L/usr/local/lib/perl5/5.24/mach/CORE -lperl
-Dshrpldflags=$(LDDLFLAGS​:N-
L/usr/ports/obj/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4​:N-
L/usr/local/lib/perl5/5.24/mach/CORE​:N-lperl) -Wl,-soname,$(LIBPERL​:R)
-Doptimize=-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2
-march=native -fno-strict-aliasing -march=corei7 -fstack-protector
-Ui_gdbm -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
Compiler​:
cc='/usr/local/bin/clang38', ccflags ='-DHAS_FPSETMASK
-DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-
strong -I/usr/local/include -D_FORTIFY_SOURCE=2',
optimize='-O3 -pipe -msse3 -msse2 -msse -mmmx -msse4.1 -msse4.2
-march=native -fno-strict-aliasing -march=corei7 -fstack-protector',
cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing
-pipe -fstack-protector-strong -I/usr/local/include'
ccversion='', gccversion='4.2.1 Compatible Clang 3.8.1
(tags/RELEASE_381/final)', 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='/usr/local/bin/clang38', ldflags ='-lpthread -Wl,-E -fstack-
protector-strong -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
/usr/local/llvm38/bin/../lib/clang/3.8.1/lib /usr/lib
libs=-lpthread -lm -lcrypt -lutil
perllibs=-lpthread -lm -lcrypt -lutil
libc=, so=so, useshrplib=true, libperl=libperl.so.5.24.1
gnulibc_version=''
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'

Locally applied patches​:
RC4

---
@​INC for perl 5.24.1​:
/usr/local/lib/perl5/site_perl/mach/5.24
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.24/mach
/usr/local/lib/perl5/5.24

---
Environment for perl 5.24.1​:
HOME=/root
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/sbin​:/bin​:/usr/sbin​:/usr/bin​:/usr/games​:/usr/local/sbin​:/usr/local/bin​:/root/bin
PERL_BADLANG (unset)
SHELL=/bin/csh

----

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 5, 2016

From @jkeenan

leaked REGEXP(0x13b8d78) from leak.pl line 18.
  17​: # no warnings;
  18​: $t =~ s{$v1}{$v2}gee;
  19​: # use warnings FATAL => 'all';
SV = REGEXP(0x13be9d0) at 0x13b8d78
  REFCNT = 1
  FLAGS = ()
  PV = 0x13c4620 "(?^​:(\\b)([a ])(?​:13[;]12)3213(\\b) )"
  CUR = 35
  COMPFLAGS = 0x0 ()
  EXTFLAGS = 0x610000 (NO_INPLACE_SUBST,USE_INTUIT_NOML,USE_INTUIT_ML)
  ENGINE = 0x57d580 (STANDARD)
  INTFLAGS = 0x0 ()
  NPARENS = 3
  LASTPAREN = 0
  LASTCLOSEPAREN = 0
  MINLEN = 11
  MINLENRET = 11
  GOFS = 0
  PRE_PREFIX = 4
  SUBLEN = 0
  SUBOFFSET = 0
  SUBCOFFSET = 0
  SUBBEG = 0x0
  MOTHER_RE = 0x0
  PAREN_NAMES = 0x0
  SUBSTRS = 0x13be330
  PPRIVATE = 0x13a75f0
  OFFS = 0x13c4550
  QR_ANONCV = 0x0
  SAVED_COPY = 0x0
leaked SCALAR(0x13b8d30) from leak.pl line 18.
  17​: # no warnings;
  18​: $t =~ s{$v1}{$v2}gee;
  19​: # use warnings FATAL => 'all';
SV = PVMG(0x13bb230) at 0x13b8d30
  REFCNT = 1
  FLAGS = (SMG,POK,IsCOW,pPOK)
  PV = 0x13bca80 "13;123213 "\0
  CUR = 10
  LEN = 16
  COW_REFCNT = 0
  MAGIC = 0x13be2f0
  MG_VIRTUAL = &PL_vtbl_regexp
  MG_TYPE = PERL_MAGIC_bm(B)
  MG_LEN = 256
  MG_PTR = 0x13c0990 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\2\3\1\n\n\n\n\n\n\n\7\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  USEFUL = 100

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 5, 2016

From @demerphq

On 5 December 2016 at 02​:14, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

I built perl 5 blead and installed Test​::LeakReport against it.

#####
$ ./bin/perl -v | head -2 | tail -1
This is perl 5, version 25, subversion 8 (v5.25.8 (v5.25.7-50-g4f738c7)) built for x86_64-linux
#####
$ cat my-leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
BLEADPERL=/home/jkeenan/testing/blead/bin/perl
$BLEADPERL -MTest​::LeakTrace​::Script=-verbose leak.pl 2> $t'_leak_report.txt'
#####
sh my-leak-report.sh
#####

When I expected the leak report (attached), I did not see the long (12 leakages) leak report than you and I got at 5.24.0 -- only a short (2 leadages) report.

Is it possible that the problem has already been corrected?

Yes. A patch I worked on with various others, including Karl was
applied to fix this problem.

As far as I know this was not a true "leak" as once the regex
terminated the memory would be freed, but to a user it would manifest
as one.

What were other 2 leakages?

Yves

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 5, 2016

From @demerphq

On 5 December 2016 at 11​:19, demerphq <demerphq@​gmail.com> wrote​:

On 5 December 2016 at 02​:14, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

I built perl 5 blead and installed Test​::LeakReport against it.

#####
$ ./bin/perl -v | head -2 | tail -1
This is perl 5, version 25, subversion 8 (v5.25.8 (v5.25.7-50-g4f738c7)) built for x86_64-linux
#####
$ cat my-leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
BLEADPERL=/home/jkeenan/testing/blead/bin/perl
$BLEADPERL -MTest​::LeakTrace​::Script=-verbose leak.pl 2> $t'_leak_report.txt'
#####
sh my-leak-report.sh
#####

When I expected the leak report (attached), I did not see the long (12 leakages) leak report than you and I got at 5.24.0 -- only a short (2 leadages) report.

Is it possible that the problem has already been corrected?

Yes. A patch I worked on with various others, including Karl was
applied to fix this problem.

Eg​:

commit 7eec73e
Author​: Yves Orton <demerphq@​gmail.com>
Date​: Fri Jun 10 12​:20​:20 2016 +0200

  move warning text to RExC_state (via RExC_warn_text)

  This way we reuse the same AV each time, and avoid various
refcount bookkeeping issues, all at a

commit ee072c8
Author​: Yves Orton <demerphq@​gmail.com>
Date​: Wed Jun 8 18​:42​:30 2016 +0200

  [perl #128313] Fix leak in perl 5.24 with strict and regex posix
char classes

  This patch is a refinement of one written by Dan Collins.

  Any thanks for this patch should go to him.

Yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 6, 2016

From bitcard-120630@kirpa.com

On Mon, 05 Dec 2016 02​:19​:53 -0800, demerphq wrote​:

On 5 December 2016 at 02​:14, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used
within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

I built perl 5 blead and installed Test​::LeakReport against it.

#####
$ ./bin/perl -v | head -2 | tail -1
This is perl 5, version 25, subversion 8 (v5.25.8 (v5.25.7-50-
g4f738c7)) built for x86_64-linux
#####
$ cat my-leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
BLEADPERL=/home/jkeenan/testing/blead/bin/perl
$BLEADPERL -MTest​::LeakTrace​::Script=-verbose leak.pl 2>
$t'_leak_report.txt'
#####
sh my-leak-report.sh
#####

When I expected the leak report (attached), I did not see the long
(12 leakages) leak report than you and I got at 5.24.0 -- only a
short (2 leadages) report.
5.24.0 and 5.24.1-RC4 report 12 leakages
5.25.7 - report 2 leakages

Is it possible that the problem has already been corrected?

Yes. A patch I worked on with various others, including Karl was
applied to fix this problem.

As far as I know this was not a true "leak" as once the regex
terminated the memory would be freed, but to a user it would manifest
as one.
This is real "leak" - my task grow up to 7-8GB (500K lines * 50 regexp = 25M "not a true leak").
Current workarround (no warnings; use warnings FATAL => 'all';) solve problem, but I prefer see warnings.

What were other 2 leakages?
please see
MG_VIRTUAL = &PL_vtbl_regexp
mg_vtable.h​:225 #define PL_vtbl_regexp PL_magic_vtables[want_vtbl_regexp]

Yves
Alexander Kirpa

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 6, 2016

From @iabyn

On Mon, Dec 05, 2016 at 06​:30​:01PM -0800, Alexander Kirpa via RT wrote​:

On Mon, 05 Dec 2016 02​:19​:53 -0800, demerphq wrote​:

On 5 December 2016 at 02​:14, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

On Sun, 04 Dec 2016 00​:38​:47 GMT, ank_120630 wrote​:

Sorry for unsuccessful content.
Please see clear text below​:
-----
Huge memory leak in case not very clean regular expression used
within
cycle.
Perl don't report any warnings or errors, but 'no warnings' pragma
eliminates memory leak.

Problem exists only in perl 5.24. Versions 5.20 and 5.22 do not have
this problem.

I built perl 5 blead and installed Test​::LeakReport against it.

#####
$ ./bin/perl -v | head -2 | tail -1
This is perl 5, version 25, subversion 8 (v5.25.8 (v5.25.7-50-
g4f738c7)) built for x86_64-linux
#####
$ cat my-leak-report.sh
t=$(date +'%Y%m%d%H%M%S')
BLEADPERL=/home/jkeenan/testing/blead/bin/perl
$BLEADPERL -MTest​::LeakTrace​::Script=-verbose leak.pl 2>
$t'_leak_report.txt'
#####
sh my-leak-report.sh
#####

When I expected the leak report (attached), I did not see the long
(12 leakages) leak report than you and I got at 5.24.0 -- only a
short (2 leadages) report.
5.24.0 and 5.24.1-RC4 report 12 leakages
5.25.7 - report 2 leakages

Is it possible that the problem has already been corrected?

Yes. A patch I worked on with various others, including Karl was
applied to fix this problem.

As far as I know this was not a true "leak" as once the regex
terminated the memory would be freed, but to a user it would manifest
as one.
This is real "leak" - my task grow up to 7-8GB (500K lines * 50 regexp = 25M "not a true leak").
Current workarround (no warnings; use warnings FATAL => 'all';) solve problem, but I prefer see warnings.

I agree that if you replace the 'for (1..5)' with an infinite loop, then
under 5.24.0 the process will grow without bounds.

Under blead that leak has been fixed.

What were other 2 leakages?
please see
MG_VIRTUAL = &PL_vtbl_regexp
mg_vtable.h​:225 #define PL_vtbl_regexp PL_magic_vtables[want_vtbl_regexp]

I think Test​::LeakTrace is wrong there. For a run-time pattern match,
during the match, perl compiles the regex then attaches it to the patten
match op. The REGEXP SV will only be freed when the code containing that
op is freed, or when it's replaced by another regex. For example with​:

  $ cat /tmp/p
  for (1..1) {
  my $pat = "a";
  "a" =
/$pat/;
  }

  $ perl5257t -Mblib -MTest​::LeakTrace​::Script=-verbose ~/tmp/p
  leaked REGEXP(0x1e11fb0) from /home/davem/tmp/p line 6.
  leaked SCALAR(0x1e320a0) from /home/davem/tmp/p line 6.
  leaked SCALAR(0x1e32070) from /home/davem/tmp/p line 6.

  change the loop to (1..5) and you get the same result.

  $ perl5257t -Mblib -MTest​::LeakTrace​::Script=-verbose ~/tmp/p
  leaked REGEXP(0xedffb0) from /home/davem/tmp/p line 6.
  leaked SCALAR(0xf000a0) from /home/davem/tmp/p line 6.
  leaked SCALAR(0xf00070) from /home/davem/tmp/p line 6.

  Change the loop to be infinite, and when run (without
  Test​::LeakTrace), it shows no process growth.

  Put the pattern match in a string eval (so the match op is freed each
  time)​:

  eval q{"a" =~ /$pat/;};

  and MTest​::LeakTrace gives no output.

--
I don't want to achieve immortality through my work...
I want to achieve it through not dying.
  -- Woody Allen

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Mar 30, 2017

@iabyn - Status changed from 'open' to 'pending release'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

@p5pRT p5pRT closed this May 30, 2017
@p5pRT p5pRT added the Severity Low label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.