Hi,
I have multithreaded test programs (client and server) that I use to test some functionalities build with OpenSSL. They started to warn about memory leaks when I linked them with version 1.1. As I had to do some code changes to adapt the new version, I first thought I forget some [new] init/free code. I finally used OPENSSL_cleanup() and alikes instead of the previous litany calls ;-), but still encounters leaks. As it was hard to track them down, I write a simple server test program that wait for a client and then return without even receiving data. No certificate are loaded. Leaks are detected only when a client handshake with the server. I might be wrong, but I do not think this is a false positive. Could you please have a look at the informations below and share your feelings ? Regards, Michel. Windows _CrtDumpMemoryLeaks() output : Detected memory leaks! Dumping objects -> {4697} normal block at 0x00822660, 140 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 {4696} normal block at 0x00822608, 24 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 {4695} normal block at 0x008225B0, 24 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 {4694} normal block at 0x00822558, 24 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 {4693} normal block at 0x00822488, 148 bytes long. Data: < & X% % > 00 00 00 00 08 26 82 00 58 25 82 00 B0 25 82 00 Object dump complete. WARNING: Visual Leak Detector detected memory leaks! ---------- Block 4677 at 0x00822488: 148 bytes ---------- Leak Hash: 0x76FECFA5, Count: 1, Total 148 bytes Call Stack (TID 2904): ntdll.dll!RtlAllocateHeap() f:\dd\vctools\crt\crtw32\misc\dbgmalloc.c (56): TestsTLS-11.exe!malloc() + 0x15 bytes e:\openssl-1.1.git\crypto\mem.c (138): TestsTLS-11.exe!CRYPTO_malloc() + 0x9 bytes e:\openssl-1.1.git\crypto\mem.c (158): TestsTLS-11.exe!CRYPTO_zalloc() + 0x11 bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (174): TestsTLS-11.exe!HMAC_CTX_new() + 0xE bytes e:\openssl-1.1.git\ssl\t1_lib.c (3060): TestsTLS-11.exe!tls_decrypt_ticket() + 0x5 bytes e:\openssl-1.1.git\ssl\t1_lib.c (2994): TestsTLS-11.exe!tls_check_serverhello_tlsext_early() + 0x2F bytes e:\openssl-1.1.git\ssl\ssl_sess.c (536): TestsTLS-11.exe!ssl_get_prev_session() + 0x18 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (1181): TestsTLS-11.exe!tls_process_client_hello() + 0x11 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (804): TestsTLS-11.exe!ossl_statem_server_process_message() + 0xD bytes e:\openssl-1.1.git\ssl\statem\statem.c (609): TestsTLS-11.exe!read_state_machine() + 0xB bytes e:\openssl-1.1.git\ssl\statem\statem.c (429): TestsTLS-11.exe!state_machine() + 0x9 bytes e:\openssl-1.1.git\ssl\statem\statem.c (222): TestsTLS-11.exe!ossl_statem_accept() + 0xB bytes e:\openssl-1.1.git\ssl\ssl_lib.c (2908): TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes p:\mes programmes\shared\ocrypto-11\tls.cpp (1017): TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes p:\mes programmes\tests\_testsshared\teststls-11-leak - copie\testtls.cpp (202): TestsTLS-11.exe!main() + 0xB bytes f:\dd\vctools\crt\crtw32\startup\crt0.c (165): TestsTLS-11.exe!mainCRTStartup() ---------- Block 4678 at 0x00822558: 24 bytes ---------- Leak Hash: 0xEBA79111, Count: 1, Total 24 bytes Call Stack (TID 2904): ntdll.dll!RtlAllocateHeap() f:\dd\vctools\crt\crtw32\misc\dbgmalloc.c (56): TestsTLS-11.exe!malloc() + 0x15 bytes e:\openssl-1.1.git\crypto\mem.c (138): TestsTLS-11.exe!CRYPTO_malloc() + 0x9 bytes e:\openssl-1.1.git\crypto\mem.c (158): TestsTLS-11.exe!CRYPTO_zalloc() + 0x11 bytes e:\openssl-1.1.git\crypto\evp\digest.c (154): TestsTLS-11.exe!EVP_MD_CTX_new() + 0xB bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (210): TestsTLS-11.exe!HMAC_CTX_reset() + 0x5 bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (177): TestsTLS-11.exe!HMAC_CTX_new() + 0x9 bytes e:\openssl-1.1.git\ssl\t1_lib.c (3060): TestsTLS-11.exe!tls_decrypt_ticket() + 0x5 bytes e:\openssl-1.1.git\ssl\t1_lib.c (2994): TestsTLS-11.exe!tls_check_serverhello_tlsext_early() + 0x2F bytes e:\openssl-1.1.git\ssl\ssl_sess.c (536): TestsTLS-11.exe!ssl_get_prev_session() + 0x18 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (1181): TestsTLS-11.exe!tls_process_client_hello() + 0x11 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (804): TestsTLS-11.exe!ossl_statem_server_process_message() + 0xD bytes e:\openssl-1.1.git\ssl\statem\statem.c (609): TestsTLS-11.exe!read_state_machine() + 0xB bytes e:\openssl-1.1.git\ssl\statem\statem.c (429): TestsTLS-11.exe!state_machine() + 0x9 bytes e:\openssl-1.1.git\ssl\statem\statem.c (222): TestsTLS-11.exe!ossl_statem_accept() + 0xB bytes e:\openssl-1.1.git\ssl\ssl_lib.c (2908): TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes p:\mes programmes\shared\ocrypto-11\tls.cpp (1017): TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes p:\mes programmes\tests\_testsshared\teststls-11-leak - copie\testtls.cpp (202): TestsTLS-11.exe!main() + 0xB bytes f:\dd\vctools\crt\crtw32\startup\crt0.c (165): TestsTLS-11.exe!mainCRTStartup() ---------- Block 4679 at 0x008225B0: 24 bytes ---------- Leak Hash: 0x6479AA48, Count: 1, Total 24 bytes Call Stack (TID 2904): ntdll.dll!RtlAllocateHeap() f:\dd\vctools\crt\crtw32\misc\dbgmalloc.c (56): TestsTLS-11.exe!malloc() + 0x15 bytes e:\openssl-1.1.git\crypto\mem.c (138): TestsTLS-11.exe!CRYPTO_malloc() + 0x9 bytes e:\openssl-1.1.git\crypto\mem.c (158): TestsTLS-11.exe!CRYPTO_zalloc() + 0x11 bytes e:\openssl-1.1.git\crypto\evp\digest.c (154): TestsTLS-11.exe!EVP_MD_CTX_new() + 0xB bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (214): TestsTLS-11.exe!HMAC_CTX_reset() + 0x5 bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (177): TestsTLS-11.exe!HMAC_CTX_new() + 0x9 bytes e:\openssl-1.1.git\ssl\t1_lib.c (3060): TestsTLS-11.exe!tls_decrypt_ticket() + 0x5 bytes e:\openssl-1.1.git\ssl\t1_lib.c (2994): TestsTLS-11.exe!tls_check_serverhello_tlsext_early() + 0x2F bytes e:\openssl-1.1.git\ssl\ssl_sess.c (536): TestsTLS-11.exe!ssl_get_prev_session() + 0x18 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (1181): TestsTLS-11.exe!tls_process_client_hello() + 0x11 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (804): TestsTLS-11.exe!ossl_statem_server_process_message() + 0xD bytes e:\openssl-1.1.git\ssl\statem\statem.c (609): TestsTLS-11.exe!read_state_machine() + 0xB bytes e:\openssl-1.1.git\ssl\statem\statem.c (429): TestsTLS-11.exe!state_machine() + 0x9 bytes e:\openssl-1.1.git\ssl\statem\statem.c (222): TestsTLS-11.exe!ossl_statem_accept() + 0xB bytes e:\openssl-1.1.git\ssl\ssl_lib.c (2908): TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes p:\mes programmes\shared\ocrypto-11\tls.cpp (1017): TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes p:\mes programmes\tests\_testsshared\teststls-11-leak - copie\testtls.cpp (202): TestsTLS-11.exe!main() + 0xB bytes f:\dd\vctools\crt\crtw32\startup\crt0.c (165): TestsTLS-11.exe!mainCRTStartup() ---------- Block 4680 at 0x00822608: 24 bytes ---------- Leak Hash: 0x7CF76213, Count: 1, Total 24 bytes Call Stack (TID 2904): ntdll.dll!RtlAllocateHeap() f:\dd\vctools\crt\crtw32\misc\dbgmalloc.c (56): TestsTLS-11.exe!malloc() + 0x15 bytes e:\openssl-1.1.git\crypto\mem.c (138): TestsTLS-11.exe!CRYPTO_malloc() + 0x9 bytes e:\openssl-1.1.git\crypto\mem.c (158): TestsTLS-11.exe!CRYPTO_zalloc() + 0x11 bytes e:\openssl-1.1.git\crypto\evp\digest.c (154): TestsTLS-11.exe!EVP_MD_CTX_new() + 0xB bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (218): TestsTLS-11.exe!HMAC_CTX_reset() + 0x5 bytes e:\openssl-1.1.git\crypto\hmac\hmac.c (177): TestsTLS-11.exe!HMAC_CTX_new() + 0x9 bytes e:\openssl-1.1.git\ssl\t1_lib.c (3060): TestsTLS-11.exe!tls_decrypt_ticket() + 0x5 bytes e:\openssl-1.1.git\ssl\t1_lib.c (2994): TestsTLS-11.exe!tls_check_serverhello_tlsext_early() + 0x2F bytes e:\openssl-1.1.git\ssl\ssl_sess.c (536): TestsTLS-11.exe!ssl_get_prev_session() + 0x18 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (1181): TestsTLS-11.exe!tls_process_client_hello() + 0x11 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (804): TestsTLS-11.exe!ossl_statem_server_process_message() + 0xD bytes e:\openssl-1.1.git\ssl\statem\statem.c (609): TestsTLS-11.exe!read_state_machine() + 0xB bytes e:\openssl-1.1.git\ssl\statem\statem.c (429): TestsTLS-11.exe!state_machine() + 0x9 bytes e:\openssl-1.1.git\ssl\statem\statem.c (222): TestsTLS-11.exe!ossl_statem_accept() + 0xB bytes e:\openssl-1.1.git\ssl\ssl_lib.c (2908): TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes p:\mes programmes\shared\ocrypto-11\tls.cpp (1017): TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes p:\mes programmes\tests\_testsshared\teststls-11-leak - copie\testtls.cpp (202): TestsTLS-11.exe!main() + 0xB bytes f:\dd\vctools\crt\crtw32\startup\crt0.c (165): TestsTLS-11.exe!mainCRTStartup() ---------- Block 4681 at 0x00822660: 140 bytes ---------- Leak Hash: 0x86320408, Count: 1, Total 140 bytes Call Stack (TID 2904): ntdll.dll!RtlAllocateHeap() f:\dd\vctools\crt\crtw32\misc\dbgmalloc.c (56): TestsTLS-11.exe!malloc() + 0x15 bytes e:\openssl-1.1.git\crypto\mem.c (138): TestsTLS-11.exe!CRYPTO_malloc() + 0x9 bytes e:\openssl-1.1.git\crypto\mem.c (158): TestsTLS-11.exe!CRYPTO_zalloc() + 0x11 bytes e:\openssl-1.1.git\crypto\evp\evp_enc.c (95): TestsTLS-11.exe!EVP_CIPHER_CTX_new() + 0xE bytes e:\openssl-1.1.git\ssl\t1_lib.c (3063): TestsTLS-11.exe!tls_decrypt_ticket() + 0x5 bytes e:\openssl-1.1.git\ssl\t1_lib.c (2994): TestsTLS-11.exe!tls_check_serverhello_tlsext_early() + 0x2F bytes e:\openssl-1.1.git\ssl\ssl_sess.c (536): TestsTLS-11.exe!ssl_get_prev_session() + 0x18 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (1181): TestsTLS-11.exe!tls_process_client_hello() + 0x11 bytes e:\openssl-1.1.git\ssl\statem\statem_srvr.c (804): TestsTLS-11.exe!ossl_statem_server_process_message() + 0xD bytes e:\openssl-1.1.git\ssl\statem\statem.c (609): TestsTLS-11.exe!read_state_machine() + 0xB bytes e:\openssl-1.1.git\ssl\statem\statem.c (429): TestsTLS-11.exe!state_machine() + 0x9 bytes e:\openssl-1.1.git\ssl\statem\statem.c (222): TestsTLS-11.exe!ossl_statem_accept() + 0xB bytes e:\openssl-1.1.git\ssl\ssl_lib.c (2908): TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes p:\mes programmes\shared\ocrypto-11\tls.cpp (1017): TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes p:\mes programmes\tests\_testsshared\teststls-11-leak - copie\testtls.cpp (202): TestsTLS-11.exe!main() + 0xB bytes f:\dd\vctools\crt\crtw32\startup\crt0.c (165): TestsTLS-11.exe!mainCRTStartup() Visual Leak Detector detected 5 memory leaks (10545 bytes). Largest number used: 138152 bytes. Total allocations: 611193 bytes. Visual Leak Detector is now exiting.
-- openssl-dev mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev