Memory leak in the resolver (threads)
Daniel Jacobowitz
drow@mvista.com
Fri Feb 21 19:38:00 GMT 2003
I received an interesting bug report about a small memory leak in the
resolver. Suppose that you have an application which creates a new thread
every time it wants to do a DNS lookup. In the course of the request, some
memory is allocated, in __libc_res_nsend:
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));
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++;
}
}
A sockaddr per nameserver. I can't see a logical place to free this
data, so when the thread exits, it is leaked. Does anyone have a suggestion
on how to clean this up?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
More information about the Libc-alpha
mailing list