cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: segfaulting in Curl_num_addresses on OS X and Ubuntu

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 31 Jul 2015 21:41:25 -0400

On 7/31/2015 12:47 PM, Eric Ridge wrote:
>> 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."

Right now the live doc reflects what I changed it to last night, ie this:

*If you are using libcurl from multiple threads or with the threaded
resolver (the default in Windows) the callback replacement functions
must be thread safe.*

Would you find this easier to understand:

*If you are using libcurl from multiple threads or libcurl was built
with the threaded resolver option (the default in Windows) then the
callback replacement functions must be thread safe.*

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

I think an option to disable the threaded resolver at runtime or use the
OS malloc routines when they are explicitly overridden is very unlikely
and defeats the point. The way to solve this issue on your end is either
use the OS memory functions or make the replacements thread safe.

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