cURL / Mailing Lists / curl-library / Single Mail


Re: elusive cache bug

From: Daniel Stenberg <>
Date: Mon, 15 Dec 2003 17:08:53 +0100 (CET)

On Sat, 13 Dec 2003, Giuseppe Attardi wrote:

> Further experiments seem to confirm a bug in host_callback(),
> as reported by valgrind:
> ==7430== Invalid read of size 4
> ==7430== at 0x812DB13: Curl_resolv_unlock (hostip.c:379)
> ==7430== by 0x81332B8: Curl_done (url.c:3231)
> ==7430== by 0x812D55E: curl_multi_perform (multi.c:511)
> ==7430== by 0x806F355: Retrieve(void) (crawlNT.cpp:889)
> ==7430== by 0x8070185: main (crawlNT.cpp:1035)
> ==7430== by 0x42017498: __libc_start_main (in /lib/i686/
> ==7430== by 0x804F570: (within /project/IXE/ixe/crawler/crawlNT)
> ==7430== Address 0x41E62964 is 8 bytes inside a block of size 12 free'd
> ==7430== at 0x40027DAB: free (vg_replace_malloc.c:231)
> ==7430== by 0x812CC51: hash_element_dtor (hash.c:62)
> ==7430== by 0x8139F8C: Curl_llist_remove (llist.c:136)
> ==7430== by 0x812CF39: Curl_hash_clean_with_criterium (hash.c:260)
> ==7430== by 0x812D86F: hostcache_prune (hostip.c:193)
> ==7430== by 0x812D924: cache_resolv_response (hostip.c:258)
> ==7430== by 0x812DE36: host_callback (hostip.c:555)
> ==7430== by 0x8141A45: end_hquery (ares_gethostbyname.c:145)

The ordering of this back-trace looks screwed up.,,

> In fact, I commented out the call to hostcache_prune() in
> cache_resolv_response() and the bug has disappeared.

Right, since the pruning function is the only one that actually remove entries
from the DNS cache, it isn't that weird that it works when removed! ;-)

> A proper fix requires a better understanding than mine of the relationships
> between ares and the host cache.

I've already before considered moving the prune call to improve performance
(for things like authentication and followlocation etc that make multiple name
resolve calls in one curl_easy_perform()). It may also have the added bonus
that it makes it less crash-prone!

What do you say about the attached patch? Does it make your program behave any

    Daniel Stenberg -- --
   [[ Do not send mails to this email address. They won't reach me. ]]

This email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now!

Received on 2003-12-15