cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Segfault running a threaded application

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 25 Nov 2002 17:26:54 +0100 (MET)

On Sun, 24 Nov 2002, Abe Lederman wrote:

> My test program is running on Solaris 8, uses pthreads, and version 7.10.2
> of libcurl.

> My test program takes a list of URLs, most of which cause queries to be
> executed, in either GET or POST and gets the URL in a thread.

> My main program monitors completion of the GET or POST and starts a new
> thread when a slot is available.
>
> Initially I get a curl handle for each of the threads that I am going to
> run concurrently, and I keep reusing it.

Sounds like a fair approach.

> I have timeouts set at 30 seconds, and I'm getting lots of timeouts (10 -
> 20%) - this is expected.
>
> I have set CURLOPT_DNS_USE_GLOBAL_CACHE to false (0). I wasn't sure if
> this is the default.

It is the default, but setting it to zero is quite ok.

> Before making my program multithreaded I was able to retrieve thousands of
> these URLs with no problems.

> I'm currently running my test program with 6 concurrent threads, and it
> usually fails after getting about 100 URLs.

Does it usually crash at the same place in the code? Or is it at least
related to the same piece of functionality? (This is the dns cache we're
seeing in use here.)

> When I ran the test program on a different set of URLs, one local URL and
> one URL that would always time out, repeatedly trying to retrieve between
> those and running with up to 12 threads I could not get my application to
> segfault.
>
> One example stack trace where I got the segfault is:
>
> #0 0x21fcc in Curl_llist_remove (list=0xcbff0, e=0xcfb08, user=0xd0cf8)
> at llist.c:126
> #1 0x13c5c in Curl_hash_clean_with_criterium (h=0xd0cf8,
> user=0xee007920,
> comp=0x13dc8 <hostcache_timestamp_remove>) at hash.c:271
> #2 0x13e20 in hostcache_prune (hostcache=0xd0cf8, cache_timeout=60,
> now=1038159746)
> at hostip.c:189

If you can get crashes like this again, can you detect what the problem is? I
mean, given this output I can't see what the actual problem was in the
crashing function (in my code, line 126 in llist.c is only an 'else'!). It
would help if you could show some local variables etc.

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-11-25