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

Possible memory leak in S_regclass #16293

Closed
p5pRT opened this issue Dec 8, 2017 · 7 comments
Closed

Possible memory leak in S_regclass #16293

p5pRT opened this issue Dec 8, 2017 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 8, 2017

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

Searchable as RT132548$

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2017

From pipcet@gmail.com

Created by pipcet@gmail.com

I believe the variable only_non_utf8_list in regcomp.c should be mortalized
or destroyed after use, but currently isn't. I don't know the regexp code,
so I'm not sure whether I'm missing something, but my test code reports that
this variable is leaked.

Inline Patch
diff --git a/regcomp.c b/regcomp.c
index 29af44c7a0..3ba091af8f 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -17721,6 +17721,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state,
I32 *flagp, U32 depth,   if \(\_invlist\_len\(only\_non\_utf8\_list\) \!= 0\) \{   ANYOF\_FLAGS\(ret\) |= ANYOF\_SHARED\_d\_MATCHES\_ALL\_NON\_UTF8\_NON\_ASCII\_non\_d\_WARN\_SUPER;   \} \+ \+ SvREFCNT\_dec\_NN\(only\_non\_utf8\_list\);   \}   else \{
Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.27.7:

Configured by pip at Mon Dec  4 13:27:33 UTC 2017.

Summary of my perl5 (revision 5 version 27 subversion 7) configuration:

  Platform:
    osname=linux
    osvers=4.13.0-1-amd64
    archname=x86_64-linux
    uname='linux amygdala 4.13.0-1-amd64 #1 smp debian 4.13.10-1
(2017-10-30) x86_64 gnulinux '
    config_args=''
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='g++'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/home/pip/git/emacs-c++/js/dist/include
-pthread -g3 -ggdb'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include -pthread'
    ccversion=''
    gccversion='8.0.0 20171124 (experimental)'
    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='ld'
    ldflags =' -fstack-protector-strong -g3 -ggdb -L/usr/local/lib'
    libpth=/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.0/../../../../include/c++/8.0.0
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.0/../../../../include/c++/8.0.0/x86_64-pc-linux-gnu
/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.0/../../../../include/c++/8.0.0/backward
/usr/local/lib /usr/local/lib/gcc/x86_64-pc-linux-gnu/8.0.0/include-fixed
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu
/lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64
/usr/lib64 /usr/local/lib64
    libs=-lpthread -pthread -lnsl -ldl -lm -lcrypt -lutil -lc
-lmozjs-58a1 -Wl,--whole-archive mozglue.a -Wl,--no-whole-archive
    perllibs=-lpthread -pthread -lnsl -ldl -lm -lcrypt -lutil -lc -L
/home/pip/git/emacs-c++/js/dist/bin -lmozjs-58a1 -Wl,--whole-archive
/home/pip/git/emacs-c++/js/mozglue/build/libmozglue.a
-Wl,--no-whole-archive
    libc=libc-2.25.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.25'
  Dynamic Linking:
    dlsrc=dl_none.xs
    dlext=none
    d_dlsymun=undef
    ccdlflags=''
    cccdlflags=''
    lddlflags=''



@INC for perl 5.27.7:
    lib
    /usr/local/lib/perl5/site_perl/5.27.7/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.27.7
    /usr/local/lib/perl5/5.27.7/x86_64-linux
    /usr/local/lib/perl5/5.27.7


Environment for perl 5.27.7:
    HOME=/home/pip
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/pip/git/emacs-c++/js/dist/bin:/home/pip/.cargo/bin:/home/pip/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/sbin
    LOGDIR (unset)
    PATH=/home/pip/.cargo/bin:/home/pip/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2017

From pipcet@gmail.com

perl-bug-008.diff
diff --git a/regcomp.c b/regcomp.c
index 29af44c7a0..3ba091af8f 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -17721,6 +17721,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
                 if (_invlist_len(only_non_utf8_list) != 0) {
                     ANYOF_FLAGS(ret) |= ANYOF_SHARED_d_MATCHES_ALL_NON_UTF8_NON_ASCII_non_d_WARN_SUPER;
                 }
+
+                SvREFCNT_dec_NN(only_non_utf8_list);
             }
             else {
                 /* Here there were no complemented posix classes.  That means

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2017

@khwilliamson - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2017

From @khwilliamson

Thanks for reporting this. Fixed by 4ee748a
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2017

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

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

From @khwilliamson

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

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

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

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

@p5pRT p5pRT closed this as completed Jun 23, 2018
@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant