Memory leak on set_default_locale
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Hello,
I heavily use ubuntu as a build platform to build and package C/C++ components.
Some components are checked in a valgrind environment. On some of them, I am
reported with the described memory leak due to bash.
It seems this bug has been fixed in other distros but not in Debian nor Ubuntu.
There is an old bug from bash 4.3 which can be reproduce easily that way:
```
$ 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_
==565== by 0x195E8D: xmalloc (in /bin/bash)
==565== by 0x18F51A: set_default_locale (in /bin/bash)
==565== by 0x135EE6: main (in /bin/bash)
...
```
This has been fixed in fedora that way (and the patch is still here in the
latest RPMs):
```
>cat bash-4.
diff -up bash-4.
--- bash-4.
+++ 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);
```
Do you think it is worth integrating that kind of patch in your package ?
Regards,
Stac
Note: The version embeded in 16.04 does not have the bug (although it is bash 4.3) but the next releases has it (tested on 18.04 and 19.10). Also tested on Debian Buster.