Calling OpenSSL_thread_stop() multiple times
Dipak B
deepak.redmi2 at gmail.com
Tue Aug 22 18:40:48 UTC 2023
On Tue, Aug 22, 2023, 9:24 PM Matt Caswell <matt at openssl.org> wrote:
>
>
> On 22/08/2023 15:43, Dipak B wrote:
> > Is it okay to call openssl_stop_thread() on a thread and then again use
> > that thread for TLS communication ? In effect end up calling
> > open_ssl_thread() multiple times on same thread.
>
> No. Don't do that. Some things get initialised on first use in a thread.
> The initialisation never gets run again, so if they get deinitialised
> they remain deinitialised forever on that thread.
>
> Matt
>
Not calling Openssl_stop_thread() leads to memory leaks inside
ERR_get_error() for me.
_malloc_base+0x44
CRYPTO_zalloc+0x54
ossl_err_get_state_int+0x9E
ERR_clear_error+0x14
ossl_send+0x45
ssl_cf_send+0x36
Curl_write+0x3C
Curl_buffer_send+0x11B
Curl_http_bodysend+0x706
Curl_http+0xAAA
multi_runsingle+0x7F4
curl_multi_perform+0x80
curl_easy_perform+0x137
So, can following be supported?
Communicate.DLL statically linked to ossl 3.x & libcurl 8.x exporting 3
functions
Initialize()
{
SSL_library_init(); or openssl_int_ssl(load no err strings)
curl_global_init();
curl_easy_init(); // multiple times generating curl handles to be stored in
array of say 16
}
Shutdown
{
curl_easy_cleanup(); // multiples times for each handle inside array
Openssl_stop_thread(); // once for each curl handle; so 16 times
curl_global_cleanup();
}
TalkToWeb
{
setup_curl_options();
curl_easy_perform();
// openssl_stop_thread(); // having this here solves the memory leak for me
}
TalkToWeb() is called by new threads (each invocation is with new thread)
created by an executable which loads communicate.DLL
Execution of above code leads to accumulation of memory until Shutdown() is
called.
Libcurl encourages handle re-use.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mta.openssl.org/pipermail/openssl-users/attachments/20230823/c7ba7a50/attachment.htm>
More information about the openssl-users
mailing list