tags 598870 + patch
quit

How about this patch?  The upstream mailing list bounced it.
From: Jonathan Nieder <jrnie...@gmail.com>
To: valgrind-us...@lists.sourceforge.net
Cc: 
Bcc: 
Subject: [PATCH] Add suppression for libnss_compat leak
Reply-To: 
User-Agent: Mutt/1.5.20 (2009-06-14)

Programs using getpwuid() (or getpwuid_r(), getgrouplist(), etc)
trigger a tiny one-tiny memory allocation in the glibc libnss
implementation that is not freed by __libc_freeres.  Filter it out.

Works-around: http://sourceware.org/bugzilla/show_bug.cgi?id=2314
Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
Hi,

I ran into this about a year ago, forgot about it, and experienced it
again today.  If you'd like to try:

 $ cat test.c 
 #include <unistd.h>
 #include <sys/types.h>
 #include <pwd.h>
 #include <stdio.h>

 int main(void)
 {
        struct passwd *pw = getpwuid(getuid());
        printf("Hello, %s!\n", pw->pw_gecos);
        return 0;
 }
 $ gcc -g -o test test.c
 $ valgrind --leak-check=yes --gen-suppressions=all ./test
 [...]
 HEAP SUMMARY:
     in use at exit: 160 bytes in 11 blocks
   total heap usage: 66 allocs, 55 frees, 6,430 bytes allocated

 160 (40 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss 
record 11 of 11
    at 0x4023F50: malloc (vg_replace_malloc.c:236)
    by 0x4110313: nss_parse_service_list (nsswitch.c:622)
 [...]
 {
    <insert_a_suppression_name_here>
    Memcheck:Leak
    fun:malloc
    fun:nss_parse_service_list
    fun:__nss_database_lookup
    obj:*
    obj:*
    fun:getpwuid_r@@GLIBC_2.1.2
    fun:getpwuid
    fun:main
 }
 [...]
 $ /lib/libc.so.6  | head -1
 GNU C Library (Debian EGLIBC 2.11.2-6) stable release version 2.11.2, by 
Roland McGrath et al.

According to http://bugs.debian.org/273051 this bug has been around
since at least glibc 2.3 days and the problem only shows up if you have

        passwd: compat

in your /etc/nsswitch.conf

How about this patch?

 glibc-2.X.supp.in |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/glibc-2.X.supp.in b/glibc-2.X.supp.in
index 935bd74..8727c79 100644
--- a/glibc-2.X.supp.in
+++ b/glibc-2.X.supp.in
@@ -127,6 +127,13 @@
    obj:*...@glibc_version@.*.so
 }
+{
+   glibc-bug-2314
+   Memcheck:Leak
+   fun:malloc
+   fun:nss_parse_service_list
+   fun:__nss_database_lookup
+}
 {
    glibc-2.5.x-on-SuSE-10.2-(PPC)-2b
    Memcheck:Addr4
    fun:index
-- 
1.7.2.3

Reply via email to