Hello, Currently 'apps_shutdown()' in 'openssl.c' isn't freeing the compression methods. This is causing the CRT debug heap (and I assume various other tools) to indicate a memory leak. Though OS will free all the resources when user-mode application exits, it's better to do this explicitly inside 'apps_shutdown()'. As a bonus this change also helps to reach the clean state where debug heap is happy :-)
Thank you, Gunnar Kudrjavets
>From 108f2ef97d866d3750aac0dbe91cffe68e8b5181 Mon Sep 17 00:00:00 2001 From: Gunnar Kudrjavets <[email protected]> Date: Wed, 13 May 2015 09:25:02 -0700 Subject: [PATCH] Fix memory leak caused by not calling SSL_COMP_free_compression_methods() Currently 'apps_shutdown()' in 'openssl.c' isn't freeing the compression methods. This is causing the CRT debug heap (and I assume various other tools) to indicate a memory leak. Though OS will free all the resources when user-mode application exits, it's better to do this explicitly inside 'apps_shutdown()'. As a bonus this change also helps to reach the clean state where debug heap is happy :-) CRT debug heap indicating that there's a leak: Detected memory leaks! Dumping objects -> {3375} normal block at 0x0AE76FE8, 16 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 {3374} normal block at 0x079A2FE8, 20 bytes long. Data: < o > 00 00 00 00 E8 6F E7 0A 00 00 00 00 04 00 00 00 Object dump complete. Stack trace pointing to the allocation which causes the leak: 0:000> | . 0 id: 84c create name: openssl.exe 0:000> kcn # 00 MSVCR120D!_heap_alloc_dbg_impl 01 MSVCR120D!_nh_malloc_dbg_impl 02 MSVCR120D!_nh_malloc_dbg 03 MSVCR120D!malloc 04 LIBEAY32!default_malloc_ex 05 LIBEAY32!CRYPTO_malloc 06 LIBEAY32!sk_new 07 SSLEAY32!load_builtin_compressions 08 SSLEAY32!SSL_COMP_get_compression_methods 09 SSLEAY32!SSL_library_init 0a openssl!apps_startup 0b openssl!main 0c openssl!__tmainCRTStartup 0d openssl!mainCRTStartup 0e KERNEL32!BaseThreadInitThunk 0f ntdll!__RtlUserThreadStart 10 ntdll!_RtlUserThreadStart --- apps/openssl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openssl.c b/apps/openssl.c index fa3b683..952eaa4 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -188,6 +188,7 @@ static void apps_shutdown() CONF_modules_unload(1); #ifndef OPENSSL_NO_COMP COMP_zlib_cleanup(); + SSL_COMP_free_compression_methods(); #endif OBJ_cleanup(); EVP_cleanup(); -- 1.9.5.msysgit.1
_______________________________________________ openssl-dev mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
