Re: dynamic locks don't get cleaned up
It's saddening for the problem to exist in the first place but it's more when no body gives it the time of the day. But that's life. I went and fixed the problem on my own: in crypto.h i declared: void CRYPTO_cleanup(); and in cryptlib.c i wrote: void CRYPTO_cleanup() { if(dyn_locks) sk_CRYPTO_dynlock_free(dyn_locks); if(app_locks) sk_OPENSSL_STRING_free(app_locks); } and i my own application I added a call to the newly added method: ENGINE_cleanup(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); OBJ_NAME_cleanup(-1); CRYPTO_cleanup(); Running my application with Valgrind produces the following output. That's what we'd like to see: ==3959== ==3959== HEAP SUMMARY: ==3959== in use at exit: 0 bytes in 0 blocks ==3959== total heap usage: 4,496 allocs, 4,496 frees, 137,484 bytes allocated ==3959== ==3959== All heap blocks were freed -- no leaks are possible On 10-08-18 04:28 PM, Jeff Saremi wrote: any takers from the openssl team? true, false? known issue, user error? anything? On 10-08-17 04:23 PM, Jeff Saremi wrote: I apologize if this shows up more than once. I've been having problems sending emails out, all day. First I encountered this with valgrind but then I decided to have openssl print the leaks and it was also confirmed. I have reduced my code to the following two lines. Prior to this if course initilization of openssl and then the cleanup. Either there's a call that I'm missing or the the dynamic locks don't get cleaned up upon exit. Looking at the code in cryptlib.c, i don't see anywhere freeing up the memory allocated to the following stacks: static STACK_OF(OPENSSL_STRING) *app_locks=NULL; static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL; And here's my sample code: int l = CRYPTO_get_new_dynlockid(); CRYPTO_destroy_dynlockid(l); Before this I have a bunch of lines like: CRYPTO_malloc_debug_init(); CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); SSL_library_init(); OpenSSL_add_all_digests(); CRYPTO_set_id_callback(..); CRYPTO_set_locking_callback(...); CRYPTO_set_dynlock_create_callback(...); CRYPTO_set_dynlock_lock_callback(...); CRYPTO_set_dynlock_destroy_callback(...); And at the end of the code I have something like: CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); CRYPTO_set_dynlock_create_callback(NULL); CRYPTO_set_dynlock_lock_callback(NULL); CRYPTO_set_dynlock_destroy_callback(NULL); ENGINE_cleanup(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); OBJ_NAME_cleanup(-1); ERR_remove_thread_state(NULL); SSL_free_comp_methods(); CRYPTO_mem_leaks_fp(stderr); As you can see I have included every cleanup call I could find. Running the code produces the following output: [19:49:10] 188 file=stack.c, line=125, thread=19596, number=20, address=08DF0E50 [19:49:10] 189 file=stack.c, line=127, thread=19596, number=16, address=08DF0F78 36 bytes leaked in 2 chunks __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: dynamic locks don't get cleaned up
any takers from the openssl team? true, false? known issue, user error? anything? On 10-08-17 04:23 PM, Jeff Saremi wrote: I apologize if this shows up more than once. I've been having problems sending emails out, all day. First I encountered this with valgrind but then I decided to have openssl print the leaks and it was also confirmed. I have reduced my code to the following two lines. Prior to this if course initilization of openssl and then the cleanup. Either there's a call that I'm missing or the the dynamic locks don't get cleaned up upon exit. Looking at the code in cryptlib.c, i don't see anywhere freeing up the memory allocated to the following stacks: static STACK_OF(OPENSSL_STRING) *app_locks=NULL; static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL; And here's my sample code: int l = CRYPTO_get_new_dynlockid(); CRYPTO_destroy_dynlockid(l); Before this I have a bunch of lines like: CRYPTO_malloc_debug_init(); CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); SSL_library_init(); OpenSSL_add_all_digests(); CRYPTO_set_id_callback(..); CRYPTO_set_locking_callback(...); CRYPTO_set_dynlock_create_callback(...); CRYPTO_set_dynlock_lock_callback(...); CRYPTO_set_dynlock_destroy_callback(...); And at the end of the code I have something like: CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); CRYPTO_set_dynlock_create_callback(NULL); CRYPTO_set_dynlock_lock_callback(NULL); CRYPTO_set_dynlock_destroy_callback(NULL); ENGINE_cleanup(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); OBJ_NAME_cleanup(-1); ERR_remove_thread_state(NULL); SSL_free_comp_methods(); CRYPTO_mem_leaks_fp(stderr); As you can see I have included every cleanup call I could find. Running the code produces the following output: [19:49:10] 188 file=stack.c, line=125, thread=19596, number=20, address=08DF0E50 [19:49:10] 189 file=stack.c, line=127, thread=19596, number=16, address=08DF0F78 36 bytes leaked in 2 chunks __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
dynamic locks don't get cleaned up
I apologize if this shows up more than once. I've been having problems sending emails out, all day. First I encountered this with valgrind but then I decided to have openssl print the leaks and it was also confirmed. I have reduced my code to the following two lines. Prior to this if course initilization of openssl and then the cleanup. Either there's a call that I'm missing or the the dynamic locks don't get cleaned up upon exit. Looking at the code in cryptlib.c, i don't see anywhere freeing up the memory allocated to the following stacks: static STACK_OF(OPENSSL_STRING) *app_locks=NULL; static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL; And here's my sample code: int l = CRYPTO_get_new_dynlockid(); CRYPTO_destroy_dynlockid(l); Before this I have a bunch of lines like: CRYPTO_malloc_debug_init(); CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); SSL_library_init(); OpenSSL_add_all_digests(); CRYPTO_set_id_callback(..); CRYPTO_set_locking_callback(...); CRYPTO_set_dynlock_create_callback(...); CRYPTO_set_dynlock_lock_callback(...); CRYPTO_set_dynlock_destroy_callback(...); And at the end of the code I have something like: CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); CRYPTO_set_dynlock_create_callback(NULL); CRYPTO_set_dynlock_lock_callback(NULL); CRYPTO_set_dynlock_destroy_callback(NULL); ENGINE_cleanup(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); OBJ_NAME_cleanup(-1); ERR_remove_thread_state(NULL); SSL_free_comp_methods(); CRYPTO_mem_leaks_fp(stderr); As you can see I have included every cleanup call I could find. Running the code produces the following output: [19:49:10] 188 file=stack.c, line=125, thread=19596, number=20, address=08DF0E50 [19:49:10] 189 file=stack.c, line=127, thread=19596, number=16, address=08DF0F78 36 bytes leaked in 2 chunks __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org