FYI - Here's my shutdown w/o any leaks... Hope this helps... make sure to check the SSL_shutdown completes, free the context & ssl pointers ;)
void http::disco(){ int shuttries=0; if ( m_url.isSSL() && m_ssl ) { while(SSL_shutdown(m_ssl)==0){ // Call SSL_shutdown() again, if the bidirectional shutdown is not yet complete if(shuttries++>3) break; } SSL_free(m_ssl); SSL_CTX_free(m_SSLctx); if(bio_err){ BIO_free(bio_err); } } if(m_fd>0) close(m_fd); m_fd= -1; ERR_free_strings(); ERR_remove_state(0); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); } -----Original Message----- From: Fred Crable Sent: Friday, December 12, 2003 10:55 AM To: '[EMAIL PROTECTED]' Subject: RE: OpenSSL 0.9.7a - Small (585 byte) memory leak Couldn't hurt to do the state(0) :) -----Original Message----- From: Anthony Neal [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 10:40 AM To: [EMAIL PROTECTED] Subject: Re: OpenSSL 0.9.7a - Small (585 byte) memory leak Thanks for the response! :) Nope, they're in there, in shutdown(): ERR_free_strings(); for_each(_threadIdCache.begin(), _threadIdCache.end(), ERR_remove_state); We actually maintain a cache of all threads that access the plugin and remove the error state for them. Unless we have to do an ERR_remove_state(0) as well? -Anthony Fred Crable wrote: > You are missing calls to: > > ERR_free_strings(); > ERR_remove_state(0); > > -----Original Message----- > From: Anthony Neal [mailto:[EMAIL PROTECTED] > Sent: Friday, December 12, 2003 9:32 AM > To: [EMAIL PROTECTED] > Subject: OpenSSL 0.9.7a - Small (585 byte) memory leak > > Hi there, > > One of our projects uses an OpenSSL based plug-in which, according to > the OpenSSL memory debug logs, is leaking about 585 bytes. The log is > as follows: > > [10:57:19] 1856 file=err.c, line=949, thread=16384, number=332, > address=08087550 > [10:57:19] 1859 file=lhash.c, line=193, thread=16384, number=12, > address=08087C78 > [10:57:19] 10692 file=err.c, line=1003, thread=16384, number=81, > address=08119160 > [10:57:19] 1857 file=lhash.c, line=119, thread=16384, number=96, > address=08087C88 > > thread=16384, file=err.c, line=415, info="int_thread_get (err.c)" > [10:57:19] 1858 file=lhash.c, line=121, thread=16384, number=64, > address=08087768 > > thread=16384, file=err.c, line=415, info="int_thread_get (err.c)" > 585 bytes leaked in 5 chunks > > The plugin starts up as follows: > > void init() > { > if(_memDebug != 0) > { > CRYPTO_malloc_debug_init(); > CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); > CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); > } > else > { > CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0); > } > > SSL_library_init(); > SSL_load_error_strings(); > OpenSSL_add_ssl_algorithms(); > } > > and shuts down as follows: > > void shutdown() > { > ENGINE_cleanup(); > CRYPTO_cleanup_all_ex_data(); > > ERR_free_strings(); > for_each(_threadIdCache.begin(), _threadIdCache.end(), > ERR_remove_state); > > EVP_cleanup(); > > if(_memDebug != 0) > { > CRYPTO_mem_leaks_fp(stderr); > } > } > > Does anyone see anything glaring that could be causing this leak? I > know some of you are much better at interpretting as to what these leaks > could be attributed. Any help would be greatly appreciated. > > Interestingly, the memory debug messages come to about 579 bytes - could > this lead be the memory used to report this error? > > -Anthony > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List [EMAIL PROTECTED] > Automated List Manager [EMAIL PROTECTED] > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List [EMAIL PROTECTED] > Automated List Manager [EMAIL PROTECTED] ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED] ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]