cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: crash using libcurl 7.19 multi interface

From: Hendrik Schober <spamtrap_at_gmx.de>
Date: Fri, 13 Mar 2009 12:40:42 +0100

Daniel Stenberg wrote:
> On Thu, 12 Mar 2009, Hendrik Schober wrote:
>
>> The new code is attached. (Note: This doesn't crash every time I start it.
>> Percentage varies widely. I suppose this is an MT issue.)
>
> MT as in multi-threading? Then nope, as the example doesn't use threads...

It does. Internally, libcurl creates a bunch of threads for the
requests. One of them crashes.

>> I have checked the code on a Linux machine. But that had libcurl 7.18.2
>> installed. I was unable to reproduce the issue on that machine.
>
> Just now I ran it quite a number of times on 7.19.4 on linux with valgrind and
> it worked fine every time! I don't have any windows box around to try on. I'm
> a bit surprised too, since the example is portable and the difference between
> linux and windows internally for this kind of stuff is not that big.
>
> When 7.19.4 crashes on windows, is the stack trace the same every time? Does
> it crash doing the same transfer? Does the code require 10 handles to get the
> crash or can it happen with less? If so, where is the limit exactly?

The stack trace is the very same, every time:
   libcurld.dll!Curl_llist_insert_next(curl_llist * list=0x01398910, curl_llist_element * e=0x035c8fe0, const void * p=0x036c1098)
Line 70 C
   libcurld.dll!Curl_hash_add(curl_hash * h=0x01398810, void * key=0x03530e88, unsigned int key_len=20, void * p=0x0363d118) Line
162 + 0x14 bytes C
   libcurld.dll!Curl_cache_addr(SessionHandle * data=0x0154fbd8, Curl_addrinfo * addr=0x0356a5a8, const char * hostname=0x0356aec8,
int port=80) Line 368 + 0x1a bytes C
   libcurld.dll!addrinfo_callback(void * arg=0x0348c0d0, int status=0, void * addr=0x01359490) Line 118 + 0x21 bytes C
   libcurld.dll!Curl_addrinfo4_callback(void * arg=0x0348c0d0, int status=0, hostent * hostent=0x01359490) Line 154 + 0x11 bytes C
   libcurld.dll!gethostbyname_thread(void * arg=0x0348c0d0) Line 264 + 0xf bytes C
   msvcr90d.dll!_callthreadstartex() Line 348 + 0xf bytes C
   msvcr90d.dll!_threadstartex(void * ptd=0x0348c6b0) Line 331 C

The real code tests with seven handles to very different URLs. I
put in those in the test so that I can quickly create as many
valid requests as I want. AFAICS, it crashes in different handles.
(At least, the URLs are different. Since those are created the
same way in a loop every time, I just assume that the handles are
different.)
With the current test, 10 handles are enough to get a crash in
about 4-8 out of 10 times I start the application. But it's not a
hard number, it's just probabilities. I've seen it working with
10,000 handles and crash with just 2.
I have the feeling that, whenever I looked closer at the crashes,
it crashed within the first ten handles, but I only have looked
closely at a few of them, so that could be accidental.
Since it always crashes in one of the threads libcurl creates
internally, and since the crashes are so unpredictable, I assume
it's a threading issue.

> Do you know of any libcurl version that worked with this?

So far, I have only upgraded from 7.19.3 to the latest version
7.19.4. We had assumed the error is on our side, so I have spent
my time mainly into boiling it down into a small self-containing
repro case.

> What Windows version are you testing this on?

This is XP SP3, latest patches installed. It also crashes on our
two Windows test machines.

Schobi
Received on 2009-03-13