[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Potential memory leaks reported by Valgrind against some frequently used commands



Hi,
As you may have known, valgrind is a powerful and easy to use tool that can be used to detect many memory management issues on Linux. Details regarding valgrind can be seen here,
http://valgrind.org

I notice that, valgrind reports memory leaks against some frequently used commands of Debian 5.0.7 and 4.0. Don't have a chance to try later releases, but I think the problem may still be there. These commands include netstat, ps -ef, ls -latr, top, etc.

I post the reports here, hope someone can look into this issue and get it resolved(pay attention to function calls in libc-2.7.so).

Environment
==============
OS: debian 5.07
debian:~# uname -a
Linux debian 2.6.26-2-686 #1 SMP Sat Nov 20 23:06:30 UTC 2010 i686 GNU/Linux

debian:/lib/i686/cmov# gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --witho ut-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1)

debian:/lib/i686/cmov# /usr/local/valgrind/bin/valgrind --version
valgrind-3.6.1


Valgrind reports
====================
1. netstat
debian:~# /usr/local/valgrind/bin/valgrind --leak-check=full netstat
==2591==
==2591== HEAP SUMMARY:
==2591==     in use at exit: 15,122 bytes in 1,125 blocks
==2591==   total heap usage: 1,367 allocs, 242 frees, 42,343 bytes allocated
==2591==
==2591== 66 (48 direct, 18 indirect) bytes in 4 blocks are definitely lost in loss record 6 of 11
==2591==    at 0x40221CA: malloc (vg_replace_malloc.c:236)
==2591==    by 0x804FE96: ??? (in /bin/netstat)
==2591==    by 0x8049E1A: ??? (in /bin/netstat)
==2591==    by 0x804A3DC: ??? (in /bin/netstat)
==2591==    by 0x804CD14: ??? (in /bin/netstat)
==2591==    by 0x4047454: (below main) (in /lib/i686/cmov/libc-2.7.so)
==2591==
==2591== LEAK SUMMARY:
==2591==    definitely lost: 48 bytes in 4 blocks
==2591==    indirectly lost: 18 bytes in 4 blocks
==2591==      possibly lost: 0 bytes in 0 blocks
==2591==    still reachable: 15,056 bytes in 1,117 blocks
==2591==         suppressed: 0 bytes in 0 blocks
==2591== Reachable blocks (those to which a pointer was found) are not shown.
==2591== To see them, rerun with: --leak-check=full --show-reachable=yes
==2591==
==2591== F or counts of detected and suppressed errors, rerun with: -v

2. ps -ef
debian:~# /usr/local/valgrind/bin/valgrind --leak-check=full ps -ef
==2597==
==2597== HEAP SUMMARY:
==2597==     in use at exit: 966 bytes in 44 blocks
==2597==   total heap usage: 390 allocs, 346 frees, 20,255 bytes allocated
==2597==
==2597== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 28 of 30
==2597==    at 0x40221CA: malloc (vg_replace_malloc.c:236)
==2597==    by 0x4144AA0: ??? (in /lib/i686/cmov/libc-2.7.so)
==2597==    by 0x414539B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==2597==    by 0x470AF5B: ???
==2597==    by 0x470D0B4: ???
==2597==    by 0x40EC011: getpwuid_r (in /lib/i686/cmov/libc-2.7.so)
==2597==    by 0x40EB996: getpwuid (in /lib/i686/cmov/libc-2.7.so)
==2597==    by 0x4035FCB: user_from_uid (in /lib/libproc-3.2.7.so)
==2597==    by 0x403735C: ??? (in /lib/libproc-3.2.7.so)
==2597==    by 0x4037D7E: readproc (in /lib/libproc-3.2.7.so)
==2597==    by 0x8049A8D: ??? (in /bin/ps)
==2597==    by 0x804A382: ??? (in /bin/ps)
==2597==
==2597== LEAK SUMMARY:
==2597==    definitely lost: 36 bytes in 1 blocks
==2597==    indirectly lost: 120 bytes in 10 blocks
==2597==      possibly lost: 0 bytes in 0 blocks
==2597==    still reachable: 810 bytes in 33 blocks
==2597==         suppressed: 0 bytes in 0 blocks
==2597== Reachable blocks (those to which a pointer was found) are not shown.
==2597== To see them, rerun with: --leak-check=full --show-reachable=yes
==2597==

3. ls -latr
debian:~# /usr/loc al/valgrind/bin/valgrind --leak-check=full ls -latr
==2592== HEAP SUMMARY:
==2592==     in use at exit: 12,680 bytes in 41 blocks
==2592==   total heap usage: 276 allocs, 235 frees, 39,123 bytes allocated
==2592==
==2592== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 27 of 29
==2592==    at 0x40221CA: malloc (vg_replace_malloc.c:236)
==2592==    by 0x414DAA0: ??? (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x414E39B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x4714F5B: ???
==2592==    by 0x47170B4: ???
==2592==    by 0x40F5011: getpwuid_r (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x40F4996: getpwuid (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x8053982: ??? (in /bin/ls)
==2592==    by 0x804AA7B: ??? (in /bin/ls)
==2592==    by 0x804B71A: ??? (in /bin/ls)
==2592==    by 0x804E006: ??? (in /bin/ls)
==2592==    by 0x804F32E: ??? (in /bin/ls)
==2592==
==2592== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 28 of 29
==2592==    at 0x40221CA: malloc (vg_replace_malloc.c:236)
==2592==    by 0x414DAA0: ??? (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x414E39B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x4713F0B: ???
==2592==    by 0x4714CEC: ???
==2592==    by 0x40F3A41: getgrgid_r (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x40F3216: getgrgid (in /lib/i686/cmov/libc-2.7.so)
==2592==    by 0x8053812: ??? (in /bin/ls)
==2592==    by 0x804BB2C: ??? (in /bin/ls)
==2592==  &nbs p; by 0x804E006: ??? (in /bin/ls)
==2592==    by 0x804F32E: ??? (in /bin/ls)
==2592==    by 0x4070454: (below main) (in /lib/i686/cmov/libc-2.7.so)
==2592==
==2592== LEAK SUMMARY:
==2592==    definitely lost: 72 bytes in 2 blocks
==2592==    indirectly lost: 240 bytes in 20 blocks
==2592==      possibly lost: 0 bytes in 0 blocks
==2592==    still reachable: 12,368 bytes in 19 blocks
==2592==         suppressed: 0 bytes in 0 blocks
==2592== Reachable blocks (those to which a pointer was found) are not shown.
==2592== To see them, rerun with: --leak-check=full --show-reachable=yes
==2592==

4. top
debian:~# /usr/local/valgrind/bin/valgrind --leak-check=full top
==2593== HEAP SUMMARY:
==2593==     in use at exit: 50,612 bytes in 96 blocks
==2593==   total heap usage: 238 allocs, 142 frees, 72,774 bytes allocated
==2593==
==2593== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 17 of 29
==2593==    at 0x40221CA: malloc (vg_replace_malloc.c:236)
==2593==    by 0x4176AA0: ??? (in /lib/i686/cmov/libc-2.7.so)
==2593==    by 0x417739B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==2593==    by 0x45E4F5B: ???
==2593==    by 0x45E70B4: ???
==2593==    by 0x411E011: getpwuid_r (in /lib/i686/cmov/libc-2.7.so)
==2593==    by 0x411D996: getpwuid (in /lib/i686/cmov/libc-2.7.so)
==2593==    by 0x4035FCB: user_from_uid (in /lib/libproc-3.2.7.so)
==2593==    by 0x403735C: ??? (in /lib/libproc-3.2.7.so)
==2593==    by 0x4037D7E: readproc (in /lib/libproc-3.2.7.so)
==2593==    by 0x804C633: ??? (in /usr/bin/top)
==2593==    by 0x8050FC0: ??? (in /usr/bin/top)
==2593==
==2593== LEAK SUMMARY:
==2593==    definitely lost: 36 bytes in 1 blocks
==2593==    indirectly lost: 120 bytes in 10 blocks
==2593==      possibly lost: 0 bytes in 0 blocks
==2593==    still reachable: 50,456 bytes in 85 blocks
==2593==         suppressed: 0 bytes in 0 blocks
==2593== Reachable blocks (those to which a pointer was found) are not shown.
==2593== To see them, rerun with: --leak-check=full --show-reachable=yes

Thanks and Best Regards,
Xmly







Reply to: