I've been doing all the development of an application in Linux (with libcurl) for a while and decided to build it in Windows 64 bit. Everything went well - it compiles no problem, etc... But when I run it, I get a crash when calling libcurl's curl_easy_perform(). More specifically:
Debug assertion failed! Expression: _CrtlsValidHeapPointer(block).
Quite puzzled I went back on Linux to run valgrind, and there were no corrupted heap blocks. Going back to Windows, I tried stripping away all the application code and just running the standard CURL tutorial code:
CURL* req = curl_easy_init();
CURLcode res;
if (req)
{
curl_easy_setopt(req, CURLOPT_URL, "www.google.com");
curl_easy_setopt(req, CURLOPT_FOLLOWLOCATION, 1L);
printf("Passed this point\n");
res = curl_easy_perform(req);
if (res != CURLE_OK)
{
fprintf(stderr, "curl_easy_operation() failed : %s\n", curl_easy_strerror(res));
}
}
curl_easy_cleanup(req);
Lo and behold, it still crashes with the same error!
My only idea as to what is wrong is that there is maybe something wrong in the build configuration? Although I have absolutely no idea what it may be for the moment...
I got hold of an older working commit of this project and ran the exact same libcurl code above in that codebase and no crash...
Upon comparing the "command line" commands that MSVC uses to compile the previous version and the current version, they seem completely identical to me (same switched, .libs and all).
Does anyone have an idea as to what might be causing a crash in a situation like this?
EDIT: The stack trace:
ntdll.dll!00007ffa809c9df2() Unknown
ntdll.dll!00007ffa8098e03a() Unknown
ntdll.dll!00007ffa80934365() Unknown
KernelBase.dll!00007ffa7e3dc99b() Unknown
ucrtbased.dll!00007ffa394c37d1() Unknown
ucrtbased.dll!00007ffa394c1b85() Unknown
ucrtbased.dll!00007ffa394c51c5() Unknown
ucrtbased.dll!00007ffa394c58c8() Unknown
vkPhysics_server.exe!Curl_setstropt() C
vkPhysics_server.exe!Curl_vsetopt() C
vkPhysics_server.exe!curl_easy_setopt() C
UPDATE: I tried tweaking an older CMake file from a previous commit, and the crash stopped. I will try to study what the difference was between the two which could possibly cause a CRT crash (for those interested, here's the diff)