cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: static link libcurl with VS2010 causes crash

From: JonathonS <thejunkjon_at_gmail.com>
Date: Tue, 21 Feb 2012 08:31:24 -0800

Thanks Gisle, Comments inline.

On Tue, Feb 21, 2012 at 12:39 AM, Gisle Vanem <gvanem_at_broadpark.no> wrote:
> "JonathonS" <thejunkjon_at_gmail.com> wrote:
>
>> stack below of the crash.
>>
>> msvcr100d.dll!_free()  + 0x10 bytes xx.dll!destroy_async_data(Curl_async *
>> async=0x003f2aa0)  Line 326 + 0xe bytes C
>
>
> What excactly is it trying to free? Who allocated the data? You must
> make sure that the allocator and the code that does the free() uses the same
> C-runtime. Same rule applies to passing 'FILE*' pointers between such
> boundaries.

I am using the "easy" interface and simply passing all data using the
CURLOPT_ functions. It looks like it is crashing when it is trying to
free (...) a URL -- the one I've passed in using CURLOPT_URL.

Does this function make a copy of this URL? or is it actually using
the pointer that I've passed in? If it trying to free (...) the
pointer I've passed in, then this crash makes sense. Is this
functionality documented anywhere? I am guessing (hoping) that curl
makes copies of all the data I've passed in using CURL_OPT_ on their
own heap or passes the pointers back to me so that I can delete them
myself.

Note that I built libcurl myself and linked dynamically, and
everything worked fine. So, this must be something specifically to
static linking.

>
>
>> I made sure to build everything using the same runtimes (/MD runtimes
>> as DLL).
>
>
> Did you make sure to build OpenSSL with '/MD' too?
> You could try to run under WinDbg and trace your program (command
> 'wt' if I remember correctly).

OpenSSL is also built using /MD. It is linked statically as well.

>
>
>> I am all out of ideas on what could be wrong with my build
>> of libcurl.  I am statically linking both openssl and libcurl which I
>> built myself.
>
>
> Statically or dynamically linking should make no difference regarding
> the rules of passing pointers between boundaries.
>
> --gv
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html

Thanks again for the help.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-02-21