Calling OpenSSL_thread_stop() multiple times

Dipak B deepak.redmi2 at gmail.com
Wed Aug 23 22:05:37 UTC 2023


On Wed, Aug 23, 2023, 7:01 PM Matt Caswell <matt at openssl.org> wrote:

>
>
> On 23/08/2023 10:54, Dipak B wrote:
> >
> > Need input on following questions.
> >
> > In the application with pseudo code as above, not using
> > Openssl_stop_thread() inside function TalkToWeb() leads to memory leak
> > which gets accumulated until function Shutdown() is called.
>  >
>  > How can I avoid memory leak  (stack shared above) ?
>  >
>
> So, IIUC, TalkToWeb is a function called by a single thread and each
> thread calls it once and then the thread exits. Is that correct?
>
> In which case calling OPENSSL_thread_stop() at the end of TalkToWeb()
> would be a good solution.
>
>
> > Can I deduct the following conclusion?
> >
> > There is constraint on an application (exe) using a DLL which is
> > statically linked to ossl. This constraint is due to openssl.
> >
> > Constraint:
> > If thread originating in such a application calls function TalkToWeb()
> > above then it has to call openssl_stop_thread() inside TalkToWeb().
> >
> > This does not allow one to re-use same thread for calling TalkToWeb().
>
> Right. You cannot re-use the same thread after calling
> OPENSSL_thread_stop(). If you wan to re-use the thread then you must
> rearrange things such that OPENSSL_thread_stop() is only called after
> the *last* time that it is reused.
>
> Matt
>
>
> >
> > Please let me know if any specific part is unclear I will try to
> > describe it.
> >
> > Thanks and Regards
> >


Thank you for all the help.
I have fixed the leak by moving Openssl_thread_stop() to dll_thread_detach.




>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mta.openssl.org/pipermail/openssl-users/attachments/20230824/5236e217/attachment-0001.htm>


More information about the openssl-users mailing list