curl / Mailing Lists / curl-library / Single Mail

curl-library

AW: Problem/Crash with libCurl Daily Snapshot and Option CURLSHOPT_SHARE and Parameter CURL_LOCK_DATA_CONNECT

From: Dawson, Patrick <Patrick.Dawson_at_zwick.de>
Date: Wed, 29 Nov 2017 06:46:53 +0000

> Dawson, Patrick wrote:
>
> > static void ShareLockFunc( CURL* pHandle, curl_lock_data Data, curl_lock_access Access, void* pUseptr )
> > {
> > ...
> > }
> >
> > static void ShareUnlockFunc( CURL* pHandle, curl_lock_data Data, void* pUseptr )
> > {
> >...
> > }
>
> Vanem, Gisle wrote:
> What are these used for?

In my understanding they are used to lock the access to the shared handle. When the connection pool is shared among the easy handles and the easy handles are manipulated by a different thread each I assume that the update of the connection cache needs to be locked: so I provided these lock functions.

> I assume if you compile with MSVC, that you've added '-EHsc'
> to your CFLAGS (otherwise the 'throw' isn't safe).

I have added -EHa but -EHsc leads to the same problems. I don't think that the problems come from my runtime exceptions.

> And BTW, your example works fine for me. Can you show some
> callstack? E.g. "cdb -c g share-lock-example.exe".

The example does not crash every time. I would say from my tests it crashes in 1 of 10 tries which leads me to the assumption that it is some kind of race condition.
I also get different call stacks.

Crash 1:
llist.c:73
list->head->prev = ne; // head is 0

Call stack:
libcurl.dll!Curl_llist_insert_next(curl_llist * list, curl_llist_element * e, const void * p, curl_llist_element * ne) Line 73 C
libcurl.dll!multi_addtimeout(Curl_easy * data, curltime * stamp, expire_id eid) Line 2887 C
libcurl.dll!Curl_expire(Curl_easy * data, __int64 milli, expire_id id) Line 2932 C
libcurl.dll!Curl_add_handle_to_pipeline(Curl_easy * handle, connectdata * conn) Line 116 C
libcurl.dll!multi_runsingle(Curl_multi * multi, curltime now, Curl_easy * data) Line 1448 C
libcurl.dll!curl_multi_perform(Curl_multi * multi, int * running_handles) Line 2168 C
libcurl.dll!easy_transfer(Curl_multi * multi) Line 683 C
libcurl.dll!easy_perform(Curl_easy * data, bool events) Line 769 C
libcurl.dll!curl_easy_perform(Curl_easy * data) Line 788 C
HttpClientDirectTest2.exe!CurlPerformGet(void * pHandle) Line 49 C++
HttpClientDirectTest2.exe!MyThreadFunction(void * lpParam) Line 131 C++
[External Code]

Crash 2:
hash.c: 114
struct curl_llist *l = FETCH_LIST(h, key, key_len); // h is 0

Call stack:
libcurl.dll!Curl_hash_add(curl_hash * h, void * key, unsigned int key_len, void * p) Line 114 C
libcurl.dll!conncache_add_bundle(conncache * connc, char * key, connectbundle * bundle) Line 189 C
libcurl.dll!Curl_conncache_add_conn(conncache * connc, connectdata * conn) Line 237 C
libcurl.dll!create_conn(Curl_easy * data, connectdata * * in_connect, bool * async) Line 4526 C
libcurl.dll!Curl_connect(Curl_easy * data, connectdata * * in_connect, bool * asyncp, bool * protocol_done) Line 4680 C
libcurl.dll!multi_runsingle(Curl_multi * multi, curltime now, Curl_easy * data) Line 1432 C
libcurl.dll!curl_multi_perform(Curl_multi * multi, int * running_handles) Line 2168 C
libcurl.dll!easy_transfer(Curl_multi * multi) Line 683 C
libcurl.dll!easy_perform(Curl_easy * data, bool events) Line 769 C
libcurl.dll!curl_easy_perform(Curl_easy * data) Line 788 C
HttpClientDirectTest2.exe!CurlPerformGet(void * pHandle) Line 49 C++
HttpClientDirectTest2.exe!MyThreadFunction(void * lpParam) Line 131 C++
[External Code]

--
Best regards
Patrick Dawson
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-11-29