cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Crash when using libcurl as part of a project - Visual Studio 2005

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 30 Oct 2007 09:42:21 +0100 (CET)

On Mon, 29 Oct 2007, Cristi wrote:

> I'm using the source code for libcurl itself in the project, i am not using
> libcurl as a dyanamic library.

I would recommend that you instead build a lib (static or DLL) and use that,
since it'll make it easier for you to upgrade to newer libcurls in the future.

> But if i use the same dll but compiled in Release mode i get a crash in
> curl_easy_perform(). I've traced through the call stack a bit and i've
> noticed that the line it fails in is from hash.c, line no 99: h = (struct
> curl_hash *) malloc(sizeof(struct curl_hash));
>
> The callstack also shows malloc.c above hash.c and the error is invalid
> access to memory location, 0x00000000.

I would say that this is due to you mixing memory "models" between various
components in your application, or that something outside of libcurl is
destroying memory somewhere at some point.

Other than so, I would recommend using some kind of memory
tracking/supervising tool (purify, valgrind or similar) to figure this out.

> it seems as though there's something wrong with the memory functions
> that curl knows about.
>
> If I compile the curlib project with the most verbose warning setting
> turned on I get the following warning:
> .\easy.c(205) : warning C4232: nonstandard extension used :
> 'Curl_cmalloc' : address of dllimport 'malloc' is not static, identity
> not guaranteed
> d:\usr\Microsoft Visual Studio 8\VC\include\stdlib.h(594) : see
> declaration of 'malloc'

What version is this? I can't see any malloc on line 205 in easy.c in any
recent version...

And anyway, this is not a problem with libcurl as I see it. It is some kind of
restriction malloc that VS seems to impose. I honestly don't understand the
warning!

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-10-30