Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15810

Memory leak detected in valgrind

From Laurent Stacul <laurent.stacul@gmail.com>
Newsgroups gnu.bash.bug
Subject Memory leak detected in valgrind
Date 2020-01-17 15:21 +0100
Message-ID <mailman.2801.1579272324.1979.bug-bash@gnu.org> (permalink)
References <CAGdu8S+SLmpHN8=q6+xnkA7auruhJh5YD22zZ6jO0GPNnOODrQ@mail.gmail.com>

Show all headers | View raw


From: Laurent Stacul <laurent.stacul@gmail.com>
To: bug-bash@gnu.org
Subject: Memory leak detected in valgrind

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
-fdebug-prefix-map=/build/bash-A6rPzY/bash-5.0=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-security
uname output: Linux docker-for-laurent 5.3.0-26-generic #28-Ubuntu SMP
Wed Dec 18 05:37:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release

Description:
        Hello dear fellows,
    I just spot that redhat GNU/Linux distributions have patched there bash
    package since the bash release 4.3:

    >cat bash-4.3-memleak-lc_all.patch
    diff -up bash-4.3/locale.c.old bash-4.3/locale.c
    --- bash-4.3/locale.c.old 2015-07-15 11:55:00.002857301 +0200
    +++ bash-4.3/locale.c 2015-07-15 11:48:36.698086257 +0200
    @@ -77,8 +77,6 @@ set_default_locale ()
     {
     #if defined (HAVE_SETLOCALE)
       default_locale = setlocale (LC_ALL, "");
    - if (default_locale)
    - default_locale = savestring (default_locale);
     #endif /* HAVE_SETLOCALE */
       bindtextdomain (PACKAGE, LOCALEDIR);
       textdomain (PACKAGE);

    And indeed, other distributions like Debian and Ubuntu suffers from a small
    memory leak (which has no consequence on a normal end user but have a few
    if you use these distributions to build, validate and deliver some C/C++
    components).

Repeat-By:
    $ env
    HOSTNAME=4288543cb792
    PWD=/
    HOME=/root
    TERM=xterm
    SHLVL=1
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    _=/usr/bin/env

    $ valgrind --leak-check=full /bin/bash -c 'exit 0'
    ...
    ==565== 2 bytes in 1 blocks are definitely lost in loss record 14 of 269
    ==565== at 0x483577F: malloc (vg_replace_malloc.c:299)
    ==565== by 0x195E8D: xmalloc (in /bin/bash)
    ==565== by 0x18F51A: set_default_locale (in /bin/bash)
    ==565== by 0x135EE6: main (in /bin/bash)
    ...

Fix:
        I don't know if the provided patch by RedHat people is the good one. You
    probably have an opinion on how to fix it properly.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Memory leak detected in valgrind Laurent Stacul <laurent.stacul@gmail.com> - 2020-01-17 15:21 +0100

csiph-web