cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Bug in libcurl in multithreaded program

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 22 May 2002 20:44:56 +0200 (MET DST)

On Wed, 22 May 2002, Avery Fay wrote:

> I recently wrote a program using libcurl that starts up a bunch of threads
> (default: 16) and has each thread repeatedly get files from an FTP server
> and web server (IIS). The program currently runs on Debian linux with
> kernel 2.4.18. libcurl version is 7.9.7 (latest). Program seg faults after
> a certain amount of time (very fast if the files are small but takes longer
> for larger files; small files make connections rapidly etc.). Here is a
> backtrace:
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1026 (LWP 21615)]
> 0x4004555c in Curl_hash_clean_with_criterium () from /usr/lib/libcurl.so.2
> (gdb) bt
> #0 0x4004555c in Curl_hash_clean_with_criterium () from
> /usr/lib/libcurl.so.2
> #1 0x4002f82f in Curl_global_host_cache_dtor () from /usr/lib/libcurl.so.2

You're using a global DNS cache here, right?

That is not thread-safe. You cannot use a global DNS cache within libcurl
when using it multi-threaded.

Switch CURLOPT_DNS_USE_GLOBAL_CACHE to FALSE and it is likely to work better.

No, there is currently no way for the different threads to share the same DNS
cache. We've discussed how to support that but we haven't implemented
anything like it yet.

If this is not the reason you have this problem, please elaborate a bit
further on what libcurl options you use and what your program actually do
libcurl-wise.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
Received on 2002-05-22