Vcpkg: Memory leaks on statically compiled CURL

Created on 21 Feb 2018  路  3Comments  路  Source: microsoft/vcpkg

Hi!

We had some leaks on our application and after using Visual Leak Detector, Deleaker, and the integrated profiler or VS2017 we found that there are leaks with minimum code.

I'm using this triplet for compiling curl:

set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

And this small application for testing it:

#include <curl/curl.h>

int main()
{
    bool testGlobal = false;

    if (testGlobal)
    {
        curl_global_init(CURL_GLOBAL_ALL);
        curl_global_cleanup();
    }
    else
    {
        CURL* curl = curl_easy_init();
        curl_easy_cleanup(curl);
    }

    return 0;
}

There are leaks in both cases, in the global one there are like 144 leaks and on easy there are 3641 leaks.
Deleaker points to this file:

mem.c, line 79 (c:\src\vcpkg\buildtrees\openssl\win32-dbg\openssl-1.0.2n\crypto\mem.c)  0x02bc8d00  326 Heap memory testCurl.exe    C:\testCurl\testCurl\Debug\testCurl.exe 15648   11140   21/02/2018 11:41:55

(there are more leaks listed like this one)

And VS2017 profiler shows this on the easy case:
curl_leak

I'm statically linking with these libraries:

libcurl.lib; libssh2.lib; libeay32.lib; ssleay32.lib; crypt32.lib; Ws2_32.lib; Wldap32.lib;

The funny thing though, is that if I use the default x86 triplet, generating DLL's, there won't appear any memory leak.

I've taken a look at curl and openssl forums/lists/etc. and found nothing clear as to how to fix this leak.
Do you have any idea?

Thanks!

Most helpful comment

@angelmixu It's a curl bug.
Personal suggestion:
When using curl, use static library of libssh will avoid the appearance of memory leaks.

All 3 comments

I think you need report this issue here https://github.com/curl/curl/issues

@angelmixu It's a curl bug.
Personal suggestion:
When using curl, use static library of libssh will avoid the appearance of memory leaks.

Closed this issue since it is a curl bug.

Was this page helpful?
0 / 5 - 0 ratings