cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Static Libcurl crashes on MSVC13

From: Jules van der Toorn <jules_at_nuisdedag.nl>
Date: Fri, 26 Feb 2016 12:22:53 +0100

Hi,
Thanks for the quick answer! I don't think it's an error in my code,
because i literally copied the code from your site, the imap-fetch
<https://curl.haxx.se/libcurl/c/imap-fetch.html> code (
curl.haxx.se/libcurl/c/imap-fetch.html), and that did work previously when
i had the dynamic libcurl library. The code is:

#*include* *<stdio.h>*
#*include* *<curl/curl.h>**int* *main*(*void*)
{
  CURL *curl;
  CURLcode res = CURLE_OK;

  curl = curl_easy_init <https://curl.haxx.se/libcurl/c/curl_easy_init.html>();
  *if*(curl) {
    */* Set username and password */ *
    curl_easy_setopt
<https://curl.haxx.se/libcurl/c/curl_easy_setopt.html>(curl,
CURLOPT_USERNAME
<https://curl.haxx.se/libcurl/c/CURLOPT_USERNAME.html>,
*"jules.vandertoorn_at_gmail.com <jules.vandertoorn_at_gmail.com>"*);
    curl_easy_setopt
<https://curl.haxx.se/libcurl/c/curl_easy_setopt.html>(curl,
CURLOPT_PASSWORD
<https://curl.haxx.se/libcurl/c/CURLOPT_PASSWORD.html>, *"my
password"*);

    */* This will fetch message 1 from the user's inbox */ *
    curl_easy_setopt
<https://curl.haxx.se/libcurl/c/curl_easy_setopt.html>(curl,
CURLOPT_URL <https://curl.haxx.se/libcurl/c/CURLOPT_URL.html>,
                     *"imaps://imap.gmail.com:993/INBOX/;UID=1
<http://imap.gmail.com:993/INBOX/;UID=1>"*);

    */* Perform the fetch */ *
    res = curl_easy_perform
<https://curl.haxx.se/libcurl/c/curl_easy_perform.html>(curl);

    */* Check for errors */ *
    *if*(res != CURLE_OK)
      fprintf(stderr, *"curl_easy_perform
<https://curl.haxx.se/libcurl/c/curl_easy_perform.html>() failed:
%s\n"*,
              curl_easy_strerror
<https://curl.haxx.se/libcurl/c/curl_easy_strerror.html>(res));

    */* Always cleanup */ *
    curl_easy_cleanup
<https://curl.haxx.se/libcurl/c/curl_easy_cleanup.html>(curl);
  }

  *return* (*int*)res;
}

The code crashes at the curl_easy_perform(curl) function, but also
later at the curl_easy_cleanup(curl) function.
I personally think something went wrong with linking it, but then i
don't understand why the simple code from the guide does work and this
one doesn't.

2016-02-26 10:58 GMT+01:00 Daniel Stenberg <daniel_at_haxx.se>:

> On Fri, 26 Feb 2016, Jules van der Toorn wrote:
>
> When i build the simple code he gave in his guide, it works great. However
>> if i use my (working with the dynamic library) mail receive program, MSVC
>> gives an error: first it says "program.exe has triggered a breakpoint", and
>> if i click continue it says: "Debug Assertion Failed!" "Expression:
>> _CrtIsValidHeapPointer(pUserData)"
>>
>
> I'm afraid that is too little information for us to do anything with.
>
> Can you run it through a debugger and tell us more precisely where it
> crashes and what the contents of the important local variables are?
>
> Honestly though, I would rather suspect a flaw in your build. Like not
> using the correct memory model or something in one of the libs you use.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-02-26