Dear community,
Can you please share insights on the following?
Background:
A Windows service periodically loads and unloads a DLL statically linked to Openssl 3.4.0.
This service has the DLL loaded always but when new version of DLL arrives, it unloads the older DLL and loads the new DLL while maintaining its PID as same. Thus service does not stop.
This DLL file calls SSL_Library_Init() once in single threaded manner as part of initialization. Later many others threads exercise Openssl.
Now everytime the host Windows service unloads my DLL using FreeLibrary() (after taking due care) and loads newer version of my DLL there is a access violation on 1st thread of my DLL
This access violation shows Openssl frames in the stack trace.
Please note that Windows service has threads that call my DLL and these threads do TLS communication. Some of these Windows service threads outlive the DLL loading and unloading.
On side note, these outliving threads leak since there is no possibility of call to OpenSSL_Stop_Thread() (DLL does not get thread detach notification)
Will dropping explicit call to SSL_Library_Init() help here in fixing access violations? Since this is OpenSSL 3.4.0 this call is not required but it is retained here since long time.
What are the important points that I should be focused on while using DLL which is statically linked to Openssl 3.4.0 in above scenario?
Are these outliving DLL threads some how cause access Violation?
Looking forward to your inputs.
Regards.