Skip to content

Annoying CRT memory leak reports with 2.7.0 build from NuGet #67

Closed
@vadz

Description

@vadz

After upgrading a simple project using the library from VS2013 with C++ REST SDK 2.1.0 to VS2015 with 2.7.0 I started getting

Detected memory leaks!
Dumping objects ->
{345} normal block at 0x014A6970, 12 bytes long.
 Data: <       Yp  Y> 01 00 00 00 D0 9D E8 59 70 B4 F4 59 
{344} normal block at 0x014A5C28, 16 bytes long.
 Data: <piJ             > 70 69 4A 01 00 00 00 00 00 00 00 00 00 00 00 00 
{343} normal block at 0x014A5BA8, 20 bytes long.
 Data: <    (\J         > 01 00 00 00 28 5C 4A 01 01 00 00 00 04 00 00 00 
Object dump complete.

on application exit. The allocation stack for the allocation 343 looks like this:

>   ucrtbased.dll!malloc(unsigned int size=0x00000014) Line 18  C++
    cpprest140d_2_7.dll!default_malloc_ex(unsigned int num=0x00000014, const char * file=0x5f226ba4, int line=0x000000a2) Line 79   C
    cpprest140d_2_7.dll!CRYPTO_malloc(int num=0x00000014, const char * file=0x5f226ba4, int line=0x000000a2) Line 342   C
    cpprest140d_2_7.dll!sk_new(int(*)(const void *, const void *) c=0x5f132460) Line 162    C
    cpprest140d_2_7.dll!load_builtin_compressions() Line 483    C
    cpprest140d_2_7.dll!SSL_COMP_get_compression_methods() Line 1949    C
    cpprest140d_2_7.dll!SSL_library_init() Line 153 C
    cpprest140d_2_7.dll!boost::asio::ssl::detail::openssl_init_base::do_init::do_init() Line 40 C++
    cpprest140d_2_7.dll!boost::asio::ssl::detail::openssl_init_base::instance() Line 131    C++
    cpprest140d_2_7.dll!boost::asio::ssl::detail::openssl_init<1>::openssl_init<1>() Line 60    C++
    cpprest140d_2_7.dll!`dynamic initializer for 'boost::asio::ssl::detail::openssl_init<1>::instance_''() Line 90  C++
    ucrtbased.dll!_initterm(void(*)() * first=0x5f206000, void(*)() * last=0x5f206684) Line 22  C++

so it seems that the real problem is that ASIO initializes OpenSSL by calling SSL_library_init(), but SSL_COMP_free_compression_methods() is not being called anywhere, however it's impossible to work around this by calling it from the application code as OpenSSL seems to be statically linked in, so perhaps it could be done from Casablanca itself?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions