Memory leak on set_default_locale

Bug #1860133 reported by Laurent Stacul
8
This bug affects 1 person
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_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)
...
```

This has been fixed in fedora that way (and the patch is still here in the
latest RPMs):

```
>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);
```

Do you think it is worth integrating that kind of patch in your package ?
Regards,
Stac

Revision history for this message
Laurent Stacul (stac47) wrote :

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.

Revision history for this message
Laurent Stacul (stac47) wrote :

Bug reported upstream too.

Revision history for this message
Laurent Stacul (stac47) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.