cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: segfaulting in Curl_num_addresses on OS X and Ubuntu

From: Eric Ridge <eebbrr_at_gmail.com>
Date: Fri, 31 Jul 2015 12:47:13 -0400

> On Jul 31, 2015, at 2:59 AM, Ray Satiro via curl-library <curl-library_at_cool.haxx.se> wrote:
>
> On 7/31/2015 12:27 AM, Eric Ridge wrote:
>> Now that I know it's possible for libcurl to create threads, it's stunningly obvious why this happens, and I've since worked around it by *not* calling curl_global_init_mem() and instead manually dealing with libcurl working outside of Postgres' transaction-based MemoryContexts, but I'd like to suggest that the curl_global_init_mem() documentation at least make a mention that a particular gotcha is concurrency.
>
> Thanks for your report. I updated the documentation in curl_global_init_mem.3 and libcurl-thread.3.
>
> https://github.com/bagder/curl/commit/0da1f5d
> https://github.com/bagder/curl/commit/23b84e4

I'm not sure this new wording would have immediately clued me in because *I'm* not using threads, libcurl is. In my mind there's a difference between a library user (me) using libcurl in a threaded program, v/s libcurl creating threads on its own.

"All callback arguments must be set to valid function pointers. libcurl might transparently use threads (<link>threaded resolver</link) that allocate memory through these callbacks, therefore thread safety is your responsibly."

> Perhaps elsewhere another warning is due for when the threaded resolver is used and the OS memory functions are not thread safe, if that configuration can happen? I will leave that for someone more experienced with the codebase.

What would be great is if the threaded resolver could just be turned off at runtime. Then again, I suppose that ship has sailed -- even with a new CURLOPT it'd be literally years before it got picked up by the distros.

Or maybe changed to just use the OS' malloc routines, although that might break curl_global_init_mem()'s contract?

> Thanks for pointing that out and your positive comments. It will be fixed soon but for now you can view it raw at https://github.com/bagder/curl/blob/master/docs/libcurl/libcurl-thread.3

Oh, that's great. Thanks.

eric

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-07-31