cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: static link libcurl with VS2010 causes crash

From: JonathonS <thejunkjon_at_gmail.com>
Date: Wed, 22 Feb 2012 17:20:59 -0800

Thanks guys for the help. I tried linking statically as described
below and it did produce a static library; however, it is still
crashing. It is crashing here in asyn-thread.c when it is trying to
free the hostname.

 /*
 * destroy_async_data() cleans up async resolver data and thread handle.
 */
static void destroy_async_data (struct Curl_async *async)
{
  if(async->hostname)
    free(async->hostname); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

  if(async->os_specific) {
    struct thread_data *td = (struct thread_data*) async->os_specific;

    if(td->thread_hnd != curl_thread_t_null)
      Curl_thread_join(&td->thread_hnd);

    destroy_thread_sync_data(&td->tsd);

    free(async->os_specific);
  }
  async->hostname = NULL;
  async->os_specific = NULL;
}

Here is how I set the hostname (URL) in my code

curlStatus = curl_easy_setopt(m_hCurl, CURLOPT_URL, szURL)

where szURL is a local char* variable.

any help would be greatly appreciated :) I've been stuck on this thing
for 2 weeks now.

Thanks,
J

On Tue, Feb 21, 2012 at 10:27 AM, Ward Willats <libcurl_at_wardco.com> wrote:
> At 8:31 AM -0800 2/21/12, JonathonS wrote:
>>
>> Note that I built libcurl myself and linked dynamically, and
>> everything worked fine.  So, this must be something specifically to
>> static linking.
>
>
> Think this free() problem is probably pilot error.
>
> I built and linked libcurl 7.32.1 and SLL statically about 2 months ago
> under Win7. Been using the output binaries from that since to HTTP POST and
> GET with the easy interface and works fine. Had to use the nmake makefiles,
> and had to patch them.
>
> In MakefileBuild.vc on line 104:
>
>     SSL=dll
>
> should be:
>
>     SSL=static
>
> ...I think Daniel fixed this. Also I had to change:
>
> winbuild/MakefileBuild.vc line 102 from:
>
> SSL_LIBS     = libeay32.lib ssleay32.lib
>
> to:
>
> SSL_LIBS     = libeay32.lib ssleay32.lib gdi32.lib user32.lib advapi32.lib
>
> ...for OpenSSL 1.0.0e linkage.
>
> My namke line (YMMV):
>
> nmake -f Makefile.vc MODE=static VC=10 WITH_SSL=static DEBUG=yes
> WITH_DEVEL=../../deps USE_SSPI=no USE_IDN=no clean
>
> I also have this cryptic note: "Need CURL_STATICLIB in cflags"
>
> -- Ward
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html

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