uWebSockets icon indicating copy to clipboard operation
uWebSockets copied to clipboard

Segmentation fault when returning SSL_CTX of the app

Open ShakyaPr opened this issue 1 year ago • 4 comments

Description:

I am experiencing a segmentation fault when attempting to retrieve the SSL context of my SSL server using the following code: SSL_CTX* sslContext = static_cast<SSL_CTX *>(_ssl_server->getNativeHandle());

Observations:

  1. Stack Trace : I used gdb to obtain the stack trace, which points to an issue in openssl.c: image

  2. Library Build : The uWebSocket library was built without the LIBUS_NO_SSL flag.

  3. Comparative Test : To isolate the issue, I created an identical HTTPS server in a separate project. In this test project, I was able to retrieve the SSL_CTX without any issues. Both projects use the same libraries and versions, but only my current development project encounters the segmentation fault.

Details:

Current Development Environment:

  • uWebSocket library built without LIBUS_NO_SSL.
  • Identical code for setting up the HTTPS server.

Test Project Environment:

  • Same uWebSocket library and version.
  • No segmentation fault when retrieving SSL_CTX.
  1. Why is there a difference in behavior between the two projects?
  2. The stack trace indicates a reference to openssl.c, which is not visited in the working test project. What could be causing this discrepancy?
  3. Are there any known issues or additional configurations needed when using uWebSockets with SSL in a specific project setup?

ShakyaPr avatar Jun 19 '24 07:06 ShakyaPr

Like always, AddressSanitizer is your friend

uNetworkingAB avatar Jun 19 '24 08:06 uNetworkingAB

Context is nullptr, why? I don't know

uNetworkingAB avatar Jun 19 '24 09:06 uNetworkingAB

We are running three server instances in three different threads. Occasionally, when creating an ssl_server object using SSLApp, the httpContext is null. Is there any reason for this? Is this socket creation isn't thread safe?

ShakyaPr avatar Jun 20 '24 12:06 ShakyaPr

Like always, AddressSanitizer is your friend

Use these tools. If you wonder about threading, use ThreadSanitizer. I don't accept bug reports of crashes without these tools being used.

uNetworkingAB avatar Jun 22 '24 10:06 uNetworkingAB