cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Memory leak using default resolver and short timeouts

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 23 Feb 2015 15:18:19 +0100

On Mon, Feb 23, 2015 at 12:54:14PM +0100, Ståle Kristoffersen wrote:
> I've discovered a memory leak which happens every time the connection
> times out while trying to connect to the DNS server. It looks like the
> default resolver using signals aren't able to clean up when aborting in
> the middle of getaddrinfo().
>
> Because our use case needs a very short timeout (10 seconds) the call to
> getaddrinfo() does not fail before the curl-timer fire. This memory leak
> disappears if we set the timeout to about 25 seconds.
>
> Will this be fixed by changing to the c-ares resolver?
> If so, are there any downsides to using it?
>
> To recreate the memory leak, change your resolv.conf to point to an IP
> address that is unreachable, then run the attached program through
> valgrind.

I'm not able to reproduce this under x86 Linux with glibc 2.18. There were
versions of glibc that leaked memory on DNS lookup failures, so it's likely
that this is what you're seeing. If that's the case, then switching libc's or
switching to c-ares should solve the problem. There aren't many downsides to
C-ares these days, mainly the lack of extensibility that glibc gives you
(i.e. /etc/nsswitch.conf)

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-02-23