On 18/02/16 11:37, Michel wrote: > Hi Matt, > > Here under is the new results after applying your patch. > Let me know anything I could do to investigate deeper.
Thanks. That was very helpful. I think I may have identified the issue. Please can you try the attached patch and see if that fixes things? Thanks Matt > > Regards, > > Michel. > > Thread serveur 5324 demarre > Thread client 6348 demarre > OPENSSL_INIT: ossl_init_base: Setting up stop handlers > OPENSSL_INIT: ossl_init_add_all_ciphers: openssl_add_all_ciphers_internal() > OPENSSL_INIT: ossl_init_add_all_digests: openssl_add_all_digests_internal() > OPENSSL_INIT: ossl_init_ssl_base: Adding SSL ciphers and digests > OPENSSL_INIT: ossl_init_ssl_base: SSL_COMP_get_compression_methods() > OPENSSL_INIT: ossl_init_ssl_base: SSL_add_ssl_module() > OPENSSL_INIT: ossl_init_load_ssl_strings: ERR_load_SSL_strings() > OPENSSL_INIT: ossl_init_async: async_init() > OPENSSL_INIT: ossl_init_load_crypto_strings: > err_load_crypto_strings_intern() > OPENSSL_INIT: ossl_init_get_thread_local: Starting: Local value is NULL, > alloc is 1 (6348) > OPENSSL_INIT: ossl_init_get_thread_local: Allocating a new local structure > (6348) > OPENSSL_INIT: ossl_init_get_thread_local: Ending: Local value is NOT NULL, > alloc is 1 (6348) > OPENSSL_INIT: ossl_init_thread_start: Starting (6348) > OPENSSL_INIT: ossl_init_thread_start: marking thread for err_state (6348) > OPENSSL_INIT: ossl_init_thread_start: End (6348) > OPENSSL_INIT: ossl_init_get_thread_local: Starting: Local value is NULL, > alloc is 1 (5324) > OPENSSL_INIT: ossl_init_get_thread_local: Allocating a new local structure > (5324) > OPENSSL_INIT: ossl_init_get_thread_local: Ending: Local value is NOT NULL, > alloc is 1 (5324) > OPENSSL_INIT: ossl_init_thread_start: Starting (5324) > OPENSSL_INIT: ossl_init_thread_start: marking thread for err_state (5324) > OPENSSL_INIT: ossl_init_thread_start: End (5324) > ... > OPENSSL_INIT: OPENSSL_thread_stop: starting (6348) > OPENSSL_INIT: ossl_init_get_thread_local: Starting: Local value is NOT NULL, > alloc is 0 (6348) > OPENSSL_INIT: ossl_init_get_thread_local: Clearing Thread Locals (6348) > OPENSSL_INIT: ossl_init_get_thread_local: Ending: Local value is NOT NULL, > alloc is 0 (6348) > OPENSSL_INIT: ossl_init_thread_stop: starting (6348) > OPENSSL_INIT: ossl_init_thread_stop: ERR_remove_thread_state(NULL) (6348) > OPENSSL_INIT: OPENSSL_thread_stop: starting (5324) > OPENSSL_INIT: ossl_init_get_thread_local: Starting: Local value is NULL, > alloc is 0 (5324) > OPENSSL_INIT: ossl_init_get_thread_local: Clearing Thread Locals (5324) > OPENSSL_INIT: ossl_init_get_thread_local: Ending: Local value is NULL, alloc > is 0 (5324) > OPENSSL_INIT: ossl_init_thread_stop: starting (5324) > OPENSSL_INIT: ossl_init_thread_stop: locals are NULL returning (5324) > OPENSSL_INIT: OPENSSL_thread_stop: ending (5324) > OPENSSL_INIT: ossl_init_thread_stop: end (6348) > OPENSSL_INIT: OPENSSL_thread_stop: ending (6348) > > Thread serveur 5324 termine > Thread client 6348 termine > > OPENSSL_INIT: ossl_init_get_thread_local: Starting: Local value is NULL, > alloc is 0 (6240) > OPENSSL_INIT: ossl_init_get_thread_local: Clearing Thread Locals (6240) > OPENSSL_INIT: ossl_init_get_thread_local: Ending: Local value is NULL, alloc > is 0 (6240) > OPENSSL_INIT: ossl_init_thread_stop: starting (6240) > OPENSSL_INIT: ossl_init_thread_stop: locals are NULL returning (6240) > OPENSSL_INIT: ssl_library_stop: SSL_COMP_free_compression_methods() > OPENSSL_INIT: ssl_library_stop: ERR_free_strings() > OPENSSL_INIT: OPENSSL_cleanup: ERR_free_strings() > OPENSSL_INIT: OPENSSL_INIT_library_stop: CRYPTO_cleanup_all_ex_data() > OPENSSL_INIT: OPENSSL_INIT_library_stop: EVP_cleanup() > OPENSSL_INIT: OPENSSL_INIT_library_stop: CONF_modules_free() > OPENSSL_INIT: OPENSSL_INIT_library_stop: RAND_cleanup() > Assertion failed: !bLeak, file p:\mes > programmes\tests\_testsshared\teststls-11\testtls.cpp, line 165 > > Detected memory leaks! > Dumping objects -> > {7025} normal block at 0x00A75628, 8 bytes long. > Data: < > 00 00 00 00 01 00 00 00 > {5009} normal block at 0x00A3CB88, 12 bytes long. > Data: < 4 > A8 0C A4 00 00 00 00 00 C0 34 01 00 > {5008} normal block at 0x00A40CA8, 400 bytes long. > Data: < > 00 00 00 00 C0 17 00 00 00 00 00 00 00 00 00 00 > {5003} normal block at 0x00A3CCB8, 64 bytes long. > Data: < > 88 CB A3 00 00 00 00 00 00 00 00 00 00 00 00 00 > {5001} normal block at 0x00A3C9B0, 96 bytes long. > Data: < P9P p9P > B8 CC A3 00 50 39 50 00 70 39 50 00 08 00 00 00 > Object dump complete. > > WARNING: Visual Leak Detector detected memory leaks! > ---------- Block 4993 at 0x00A3C9B0: 96 bytes ---------- > Leak Hash: 0x7CDBED0B, Count: 1, Total 96 bytes > Call Stack (TID 4804): > 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 (141): TestsTLS-11.exe!CRYPTO_malloc() + > 0x9 bytes > e:\openssl-1.1.git\crypto\mem.c (161): TestsTLS-11.exe!CRYPTO_zalloc() + > 0x11 bytes > e:\openssl-1.1.git\crypto\lhash\lhash.c (116): TestsTLS-11.exe!lh_new() > + 0xE bytes > e:\openssl-1.1.git\crypto\err\err_lcl.h (2): > TestsTLS-11.exe!lh_ERR_STATE_new() + 0x10 bytes > e:\openssl-1.1.git\crypto\err\err.c (321): > TestsTLS-11.exe!int_thread_get() + 0xF bytes > e:\openssl-1.1.git\crypto\err\err.c (369): > TestsTLS-11.exe!int_thread_set_item() + 0x9 bytes > e:\openssl-1.1.git\crypto\err\err.c (884): > TestsTLS-11.exe!ERR_get_state() + 0xC bytes > e:\openssl-1.1.git\crypto\err\err.c (598): > TestsTLS-11.exe!ERR_clear_error() + 0x5 bytes > e:\openssl-1.1.git\ssl\statem\statem.c (279): > TestsTLS-11.exe!state_machine() > e:\openssl-1.1.git\ssl\statem\statem.c (217): > TestsTLS-11.exe!ossl_statem_connect() + 0xB bytes > e:\openssl-1.1.git\ssl\ssl_lib.c (2905): > TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes > p:\mes programmes\shared\ocrypto-11\tls.cpp (953): > TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes > p:\mes programmes\tests\_testsshared\teststls-11\clttasks.cpp (64): > TestsTLS-11.exe!CltThread::Main() + 0xB bytes > p:\mes programmes\shared\sthread.cpp (17): > TestsTLS-11.exe!SThread::Run() + 0xE bytes > f:\dd\vctools\crt\crtw32\startup\threadex.c (359): > TestsTLS-11.exe!_threadstartex() > > > ---------- Block 5001 at 0x00A3CB88: 12 bytes ---------- > Leak Hash: 0xE9B700C5, Count: 1, Total 12 bytes > Call Stack (TID 6080): > 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 (141): TestsTLS-11.exe!CRYPTO_malloc() + > 0x9 bytes > e:\openssl-1.1.git\crypto\lhash\lhash.c (168): > TestsTLS-11.exe!lh_insert() + 0x11 bytes > e:\openssl-1.1.git\crypto\err\err_lcl.h (2): > TestsTLS-11.exe!lh_ERR_STATE_insert() + 0x10 bytes > e:\openssl-1.1.git\crypto\err\err.c (371): > TestsTLS-11.exe!int_thread_set_item() + 0xD bytes > e:\openssl-1.1.git\crypto\err\err.c (884): > TestsTLS-11.exe!ERR_get_state() + 0xC bytes > e:\openssl-1.1.git\crypto\err\err.c (598): > TestsTLS-11.exe!ERR_clear_error() + 0x5 bytes > e:\openssl-1.1.git\ssl\statem\statem.c (279): > TestsTLS-11.exe!state_machine() > 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 (2905): > TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes > p:\mes programmes\shared\ocrypto-11\tls.cpp (953): > TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes > p:\mes programmes\tests\_testsshared\teststls-11\srvtasks.cpp (79): > TestsTLS-11.exe!SrvThread::Main() + 0xB bytes > p:\mes programmes\shared\sthread.cpp (17): > TestsTLS-11.exe!SThread::Run() + 0xE bytes > f:\dd\vctools\crt\crtw32\startup\threadex.c (359): > TestsTLS-11.exe!_threadstartex() > > > ---------- Block 4995 at 0x00A3CCB8: 64 bytes ---------- > Leak Hash: 0x8337F4DE, Count: 1, Total 64 bytes > Call Stack (TID 4804): > 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 (141): TestsTLS-11.exe!CRYPTO_malloc() + > 0x9 bytes > e:\openssl-1.1.git\crypto\mem.c (161): TestsTLS-11.exe!CRYPTO_zalloc() + > 0x11 bytes > e:\openssl-1.1.git\crypto\lhash\lhash.c (118): TestsTLS-11.exe!lh_new() > + 0xE bytes > e:\openssl-1.1.git\crypto\err\err_lcl.h (2): > TestsTLS-11.exe!lh_ERR_STATE_new() + 0x10 bytes > e:\openssl-1.1.git\crypto\err\err.c (321): > TestsTLS-11.exe!int_thread_get() + 0xF bytes > e:\openssl-1.1.git\crypto\err\err.c (369): > TestsTLS-11.exe!int_thread_set_item() + 0x9 bytes > e:\openssl-1.1.git\crypto\err\err.c (884): > TestsTLS-11.exe!ERR_get_state() + 0xC bytes > e:\openssl-1.1.git\crypto\err\err.c (598): > TestsTLS-11.exe!ERR_clear_error() + 0x5 bytes > e:\openssl-1.1.git\ssl\statem\statem.c (279): > TestsTLS-11.exe!state_machine() > e:\openssl-1.1.git\ssl\statem\statem.c (217): > TestsTLS-11.exe!ossl_statem_connect() + 0xB bytes > e:\openssl-1.1.git\ssl\ssl_lib.c (2905): > TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes > p:\mes programmes\shared\ocrypto-11\tls.cpp (953): > TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes > p:\mes programmes\tests\_testsshared\teststls-11\clttasks.cpp (64): > TestsTLS-11.exe!CltThread::Main() + 0xB bytes > p:\mes programmes\shared\sthread.cpp (17): > TestsTLS-11.exe!SThread::Run() + 0xE bytes > f:\dd\vctools\crt\crtw32\startup\threadex.c (359): > TestsTLS-11.exe!_threadstartex() > > > ---------- Block 5000 at 0x00A40CA8: 400 bytes ---------- > Leak Hash: 0x2037555F, Count: 1, Total 400 bytes > Call Stack (TID 6080): > 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 (141): TestsTLS-11.exe!CRYPTO_malloc() + > 0x9 bytes > e:\openssl-1.1.git\crypto\err\err.c (874): > TestsTLS-11.exe!ERR_get_state() + 0x14 bytes > e:\openssl-1.1.git\crypto\err\err.c (598): > TestsTLS-11.exe!ERR_clear_error() + 0x5 bytes > e:\openssl-1.1.git\ssl\statem\statem.c (279): > TestsTLS-11.exe!state_machine() > 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 (2905): > TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes > p:\mes programmes\shared\ocrypto-11\tls.cpp (953): > TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes > p:\mes programmes\tests\_testsshared\teststls-11\srvtasks.cpp (79): > TestsTLS-11.exe!SrvThread::Main() + 0xB bytes > p:\mes programmes\shared\sthread.cpp (17): > TestsTLS-11.exe!SThread::Run() + 0xE bytes > f:\dd\vctools\crt\crtw32\startup\threadex.c (359): > TestsTLS-11.exe!_threadstartex() > > > ---------- Block 7017 at 0x00A75628: 8 bytes ---------- > Leak Hash: 0x82CA3A37, Count: 1, Total 8 bytes > Call Stack (TID 6080): > 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 (141): TestsTLS-11.exe!CRYPTO_malloc() + > 0x9 bytes > e:\openssl-1.1.git\crypto\mem.c (161): TestsTLS-11.exe!CRYPTO_zalloc() + > 0x11 bytes > e:\openssl-1.1.git\crypto\init.c (212): > TestsTLS-11.exe!ossl_init_get_thread_local() + 0x11 bytes > e:\openssl-1.1.git\crypto\init.c (568): > TestsTLS-11.exe!ossl_init_thread_start() + 0x7 bytes > e:\openssl-1.1.git\crypto\err\err.c (898): > TestsTLS-11.exe!ERR_get_state() + 0x9 bytes > e:\openssl-1.1.git\crypto\err\err.c (598): > TestsTLS-11.exe!ERR_clear_error() + 0x5 bytes > e:\openssl-1.1.git\ssl\statem\statem.c (279): > TestsTLS-11.exe!state_machine() > 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 (2905): > TestsTLS-11.exe!SSL_do_handshake() + 0xC bytes > p:\mes programmes\shared\ocrypto-11\tls.cpp (953): > TestsTLS-11.exe!OTLS::TLSSss::DoHandshake() + 0xC bytes > p:\mes programmes\tests\_testsshared\teststls-11\srvtasks.cpp (79): > TestsTLS-11.exe!SrvThread::Main() + 0xB bytes > p:\mes programmes\shared\sthread.cpp (17): > TestsTLS-11.exe!SThread::Run() + 0xE bytes > f:\dd\vctools\crt\crtw32\startup\threadex.c (359): > TestsTLS-11.exe!_threadstartex() > > > Visual Leak Detector detected 5 memory leaks (16416 bytes). > Largest number used: 442154 bytes. > Total allocations: 1908126 bytes. > >
>From 41f8a77731432586b2923dd77c523b79c9bd7025 Mon Sep 17 00:00:00 2001 From: Matt Caswell <m...@openssl.org> Date: Thu, 18 Feb 2016 12:24:09 +0000 Subject: [PATCH] Fix windows thread stop code The windows thread stop code was erroneously not just deleting the thread local variable on thread stop, but also deleting the thread local *key* (thus removing thread local data for *all* threads in one go!). --- crypto/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/init.c b/crypto/init.c index c7eff8b..106bb10 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -500,7 +500,6 @@ static void ossl_init_thread_stop(struct thread_local_inits_st *locals) } OPENSSL_free(locals); - ossl_init_thread_stop_cleanup(); } void OPENSSL_thread_stop(void) @@ -593,6 +592,8 @@ void OPENSSL_cleanup(void) ERR_free_strings(); } + ossl_init_thread_stop_cleanup(); + #ifdef OPENSSL_INIT_DEBUG fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: " "CRYPTO_cleanup_all_ex_data()\n"); -- 2.5.0
-- openssl-dev mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev