memory leak in threaded getpwuid_r() usage

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

memory leak in threaded getpwuid_r() usage

Volkan YAZICI
Hi,

Trying to use getpwuid_r() in a threaded application. (Code is attached
at the end of the message.) But in the "ps -p <PID> -o rss,size" output
of the program, RSS increases by time while SIZE remains stable.

After exploring the web, I've found some other people
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=273051) facing with
the same bug. AFAICS, there's a problem with some versions of the
libnss package. I'd be so appreciated if you can help me to figure out
the source of the problem and how can I solve it.

Tests were made using libc6 2.3.2.ds1-22 and libnss-db 2.2-6.3 on
debian stable (sarge).

Here's the (ps -p <PID> -o rss,size) output of the program:

[BEGIN:output]
$ ./a.out
user_id = 1000, proc_id = 28583
  1  700 46336
  2  704 46336
...
 47  716 46332
 48  716 46332
 49  716 46336
 50  716 46336
[END:output]

And valgrind --leak-check=full output:

[BEGIN:valgrind]
156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost in
loss record 4 of 9
   at 0x1B90459D: malloc (vg_replace_malloc.c:130)
   by 0x1BA0BEE6: (within /lib/tls/libc-2.3.2.so)
   by 0x1BA0B788: __nss_database_lookup (in /lib/tls/libc-2.3.2.so)
   by 0x1DB70AFB: ???
   by 0x1B9CCD4B: getpwuid_r (in /lib/tls/libc-2.3.2.so)
   by 0x804879A: sub_func (getpwuid.c:43)
   by 0x1B918B62: start_thread (in /lib/tls/libpthread-0.60.so)
   by 0x1B9FC189: clone (in /lib/tls/libc-2.3.2.so)

340 bytes in 5 blocks are possibly lost in loss record 8 of 9
   at 0x1B904F75: calloc (vg_replace_malloc.c:175)
   by 0x1B8F2678: (within /lib/ld-2.3.2.so)
   by 0x1B8F294B: _dl_allocate_tls (in /lib/ld-2.3.2.so)
   by 0x1B91924A: allocate_stack (in /lib/tls/libpthread-0.60.so)
   by 0x1B918C54: pthread_create@@GLIBC_2.1 (in
/lib/tls/libpthread-0.60.so)
   by 0x80488AB: main (getpwuid.c:68)
[END:valgrind]


Regards.

P.S. Please excuse me if this list is the wrong place to ask the
question. But, Debian Bug Tracking System seems like not responsive
about the related report.

getpwuid.c (1K) Download Attachment