On 21/11/2014 15:26, Barbe, Charles wrote:
Thanks for the response... here is the code that runs when my connection closes:

void OpensslConnection::cleanup()
{
     if(ssl != NULL)
     {
         if(isConnected)
         {
                while(SSL_shutdown(ssl) == 0)
                    ;
         }
         SSL_free(ssl);
         ERR_remove_state(0);
         ssl = NULL;
     }

     isConnected = false;
}

And here is the code that runs to shut down my SSL library:

static void
openSslShutdown ()
{
        CONF_modules_free();
        ERR_remove_state(0);
        CONF_modules_unload(1);
        ERR_free_strings();
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();

        if (opensslLocks != NULL)
     {
         for(int i = 0; i < CRYPTO_num_locks(); i++)
         {
             PAL_mutexDestroy (opensslLocks[i]);
         }

         IST_FREE (opensslLocks);
     }
}

Also, I have numerous worker threads handling connections and they all do the 
following before they exit:

   ERR_remove_thread_state(0);
From the response by Dr. Henson, maybe you need code to unload your
server certificate and its certificate chain (a STACK of
certificates).
________________________________________
From: owner-openssl-us...@openssl.org [owner-openssl-us...@openssl.org] on 
behalf of Jeffrey Walton [noloa...@gmail.com]
Sent: Thursday, November 20, 2014 6:03 PM
To: OpenSSL Users List
Subject: Re: Small memory leak on multithreaded server

Any help would be appreciated.
This could be one of two problems. First, it could be an issue with
your code and the way you handle cleanup. To help diagnose this,
please show us your cleanup code.

Second, it could be the memory leak from the compression methods. This
is a well known problem dating back a few years that has not been
fixed. See, for example,
http://rt.openssl.org/Ticket/Display.html?id=2561&user=guest&pass=guest.

On Thu, Nov 20, 2014 at 5:19 PM, Barbe, Charles
<charles.ba...@allworx.com> wrote:
Hello,

I have noticed a small and consistent memory leak in my multithreaded openssl 
server and am wondering if somebody can help me figure out what I need to do to 
free it when my application closes. I am on OpenSSL version 1.0.1j. Here's how 
I reproduce the leak:

1) Start up my server
2) Load my homepage with Chrome
3) Load my homepage with IE
4) Load my homepage with Firefox

I can do any combination of steps 2,3 and 4 above (ie. leave some of them out) 
and I always get the same amount of memory left over after I shut down my 
application. I believe this means that this is some sort of global information 
that OpenSSL is hanging on to and not something in my SSL connection structure.

Specifically I get 20 blocks totaling 253 bytes. I have stack traces of where 
each block is allocated but I cannot figure out how this memory should be 
cleaned up. Each of the 20 blocks filter down to 1 of 5 root stack traces. The 
stack traces are:

Repeated 6 times:


Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  http://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to