Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Sep 2005 17:03:45 +0300
From:      Lefteris Tsintjelis <lefty@ene.asda.gr>
To:        Simon Barner <barner@FreeBSD.org>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: pthread_key_create memory leakage in pthreads?
Message-ID:  <433BF441.80404@ene.asda.gr>
In-Reply-To: <20050929133156.GA72022@zi025.glhnet.mhn.de>
References:  <433BB81A.5090602@ene.asda.gr> <20050929133156.GA72022@zi025.glhnet.mhn.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Simon Barner wrote:
> 
> Can you provide a (minimal) example where this happens? Also, what is
> the exact command line?

valgrind --trace-children=yes --leak-check=yes --show-reachable=yes ./sql-m

==12024== Memcheck, a memory error detector for x86-linux.
==12024== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.
==12024== Using valgrind-2.1.0, a program supervision framework for x86-linux.
==12024== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.
==12024== Estimated CPU clock rate is 3089 MHz
==12024== For more details, rerun with: -v
==12024==
==12024== warning: Valgrind's pthread_cond_destroy is incomplete
==12024==          (it doesn't check if the cond is waited on)
==12024==          your program may misbehave as a result
==12024== warning: Valgrind's pthread_cond_destroy is incomplete
==12024==          (it doesn't check if the cond is waited on)
==12024==          your program may misbehave as a result
==12024==
==12024== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==12024== malloc/free: in use at exit: 33100 bytes in 22 blocks.
==12024== malloc/free: 6051 allocs, 6029 frees, 24774738 bytes allocated.
==12024== For counts of detected errors, rerun with: -v
==12024== searching for pointers to 22 not-freed blocks.
==12024== checked 2119764 bytes.
==12024==
==12024== 52 bytes in 1 blocks are still reachable in loss record 1 of 5
==12024==    at 0x3C036967: calloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==12024==    by 0x3C050F6C: my_thread_init (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==    by 0x3C050E4A: my_thread_global_init (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==    by 0x3C04C158: my_init (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==
==12024==
==12024== 136 bytes in 12 blocks are still reachable in loss record 2 of 5
==12024==    at 0x3C03619F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==12024==    by 0x3C0978EC: (within /usr/local/lib/valgrind/libpthread.so.1)
==12024==    by 0x3C098F65: pthread_mutex_init (in /usr/local/lib/valgrind/libpthread.so.1)
==12024==    by 0x3C050D95: my_thread_global_init (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==
==12024==
==12024== 200 bytes in 1 blocks are definitely lost in loss record 3 of 5
==12024==    at 0x3C03619F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==12024==    by 0x3C0978EC: (within /usr/local/lib/valgrind/libpthread.so.1)
==12024==    by 0x3C09A2FD: (within /usr/local/lib/valgrind/libpthread.so.1)
==12024==    by 0x3C09A489: pthread_key_create (in /usr/local/lib/valgrind/libpthread.so.1)
==12024==
==12024==
==12024== 4096 bytes in 1 blocks are still reachable in loss record 4 of 5
==12024==    at 0x3C03619F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==12024==    by 0x3C17B4B9: __smakebuf (in /lib/libc.so.5)
==12024==    by 0x3C17B416: __swsetup (in /lib/libc.so.5)
==12024==    by 0x3C16FC39: __vfprintf (in /lib/libc.so.5)
==12024==
==12024==
==12024== 28616 bytes in 7 blocks are still reachable in loss record 5 of 5
==12024==    at 0x3C03619F: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==12024==    by 0x3C05308A: my_once_alloc (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==    by 0x3C0534B7: init_state_maps (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==    by 0x3C053E94: init_available_charsets (in /usr/local/lib/mysql/libmysqlclient_r.so.14)
==12024==
==12024== LEAK SUMMARY:
==12024==    definitely lost: 200 bytes in 1 blocks.
==12024==    possibly lost:   0 bytes in 0 blocks.
==12024==    still reachable: 32900 bytes in 21 blocks.
==12024==         suppressed: 0 bytes in 0 blocks.

valgrind is not a native BSD program. I use it to detect program memory
leaks. However, I am not sure if in this case, is detecting its own leaks
and problems or not. It is refering to its own /usr/local/lib/valgrind/\
libpthread.so.1. sql-m is my own program that I test but I have double
checked everything and this shouldn't happen. If you need further info
about the sql-m please let me know and I will send you a copy but its a
very simple threaded one.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?433BF441.80404>