This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: memory leak in res_nsend()
- From: Daniel Jacobowitz <drow at false dot org>
- To: Antony Dovgal <tony2001 at phpclub dot net>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Mon, 24 Oct 2005 13:14:52 -0400
- Subject: Re: memory leak in res_nsend()
- References: <435CB733.8050409@phpclub.net>
On Mon, Oct 24, 2005 at 02:28:03PM +0400, Antony Dovgal wrote:
> Hello all.
>
> I get memory leak after using res_nsend() and I don't see a regular way to
> free the memory allocated in this function.
> That's what I can see in resolv/res_send.c (glibc-2.3.4):
> ...
> for (ns = 0; ns < EXT(statp).nscount; ns++) {
> n = map[ns];
> if (EXT(statp).nsaddrs[n] == NULL)
> EXT(statp).nsaddrs[n] =
> malloc(sizeof (struct sockaddr_in6)); /* malloc() */
> if (EXT(statp).nsaddrs[n] != NULL) {
> memcpy(EXT(statp).nsaddrs[n],
> &statp->nsaddr_list[ns],
> sizeof (struct sockaddr_in));
> EXT(statp).nssocks[n] = -1;
> n++;
> }
> }
> ...
>
> But res_nclose() doesn't free those segments.
> That's what I've found in res_thread_freeres () function
> (resolv/res_init.c):
Well, when you're running under valgrind, the freeres functions are
supposed to be called - for exactly this reason. If it calls
__libc_freeres but not __libc_thread_freeres, maybe you shold report
this as a valgrind bug.
--
Daniel Jacobowitz
CodeSourcery, LLC