adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 125 forks source link

http2, OpenSslSocket segfault on Linux #329

Closed ozz-is-here closed 2 years ago

ozz-is-here commented 2 years ago

Fedora 36, LDC 1.29.0 Debian 11, LDC 1.24.0 arsd from master

When I try to use OpenSslSocket, it throws a segmentation fault. Here is an example code:

import std.stdio;
import std.socket;

import arsd.http2;

void main()
{
    OpenSslSocket sock = new OpenSslSocket(AddressFamily.INET); // this line throws a segfault
    sock.connect(new InternetAddress("google.com", 443));
    sock.send("GET / HTTP/1.1\r\n\r\n");
    char[1024] buffer;
    writeln(buffer[0 .. sock.receive(buffer)]);
}
(ldc2-1.29.0-linux-x86_64)user@desktop ~/d/ssl_socket_test> ./ssl_socket_test
[1]    946409 segmentation fault  ./ssl_socket_test

It seems like the segfault happens here: https://github.com/adamdruppe/arsd/blob/master/http2.d#L3234

adamdruppe commented 2 years ago

Call loadOpenSsl() first.

Also note these are all undocumented for a reason.... it is an internal implementation detail that this class even exists. But still if you call that load function first (if you call it multiple times it is harmless btw) it should be ok, just I never formally meant to support these long term. Maybe I will just document them at some point though.

ozz-is-here commented 2 years ago

Call loadOpenSsl() first.

Also note these are all undocumented for a reason.... it is an internal implementation detail that this class even exists. But still if you call that load function first (if you call it multiple times it is harmless btw) it should be ok, just I never formally meant to support these long term. Maybe I will just document them at some point though.

It works great now, thank you!

Sorry for such a dumb issue.

adamdruppe commented 2 years ago

I could make that class constructor call that automatically too. If I decide to document it, i will do that I think.