cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Memory leak using default resolver and short timeouts

From: Ståle Kristoffersen <staalebk_at_ifi.uio.no>
Date: Mon, 23 Feb 2015 15:52:37 +0100

On 2015-02-23 at 15:18, Dan Fandrich wrote:
> 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)

This was on a x64 machine running debian 7.6:
$ dpkg -l | grep libc6
ii libc6:amd64 2.13-38+deb7u6 amd64 Embedded GNU C Library: Shared libraries

I think this might be the issue we are hitting:
http://curl.haxx.se/mail/lib-2008-09/0197.html

-- 
Ståle Kristoffersen
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-02-23