Hello all,

As some have you may have followed, I've been working on snap-packaging LDC. However, I've run into an issue when it comes to programs that use std.net.curl.


Here's a simple example:

------------------------
void main ()
{
    import std.net.curl : get;
    auto website = "http://dlang.org/".get;
}
------------------------

When I compile with my snap-packaged LDC, the program builds, but segfaults when I run it. Here's the gdb backtrace:

Thread 1 "curlget" received signal SIGSEGV, Segmentation fault.
0x000000000046b048 in gc.gc.Gcx.smallAlloc(ubyte, ref ulong, uint) ()
(gdb) bt
#0 0x000000000046b048 in gc.gc.Gcx.smallAlloc(ubyte, ref ulong, uint) () #1 0x000000000046918a in gc.gc.GC.malloc(ulong, uint, ulong*, const(TypeInfo)) ()
#2  0x00000000004682bc in gc_qalloc ()
#3 0x000000000046293b in core.memory.GC.qalloc(ulong, uint, const(TypeInfo)) () #4 0x00000000004534f2 in std.array.Appender!(char[]).Appender.ensureAddable(ulong) () #5 0x00000000004530c5 in std.uni.toCase!(std.uni.toLowerIndex(dchar), 1043, std.uni.toLowerTab(ulong), char[]).toCase(char[]).__foreachbody2(ref ulong, ref dchar) ()
#6  0x000000000046dc96 in _aApplycd2 ()
#7 0x000000000044d997 in std.net.curl.HTTP.Impl.onReceiveHeader(void(const(char[]), const(char[])) delegate).__lambda2(const(char[])) () #8 0x0000000000451d78 in std.net.curl.Curl._receiveHeaderCallback(const(char*), ulong, ulong, void*) () #9 0x00007ffff6f7695d in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so #10 0x00007ffff6f74ed0 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so #11 0x00007ffff6f8cce0 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so #12 0x00007ffff6f96b22 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so #13 0x00007ffff6f97986 in curl_multi_perform () from /usr/lib/x86_64-linux-gnu/libcurl.so #14 0x00007ffff6f8e65b in curl_easy_perform () from /usr/lib/x86_64-linux-gnu/libcurl.so #15 0x000000000044f971 in std.net.curl.HTTP.perform(std.typecons.Flag!("throwOnError").Flag) () #16 0x000000000040db01 in std.net.curl._basicHTTP!(char)._basicHTTP(const(char)[], const(void)[], std.net.curl.HTTP) () #17 0x00000000004031ff in std.net.curl.get!(std.net.curl.HTTP, char).get(const(char)[], std.net.curl.HTTP) () #18 0x0000000000403020 in std.net.curl.get!(std.net.curl.AutoProtocol, char).get(const(char)[], std.net.curl.AutoProtocol) ()
#19 0x0000000000402f98 in D main ()

Since I'm not super-familiar with libcurl, it's a bit un-obvious what's going on here. If I understand right, libcurl is lazily loaded at runtime rather than explicitly linked. libcurl4-gnutls-dev is installed on my machine, so it can't just be lack of availability. (I've also tried uninstalling libcurl4-gnutls-dev and installing libcurl4-openssl-dev instead, with no difference in the result.)

The segfault would suggest to me that either the loading of the library fails or that there's some resource phobos expects to find which it can't access. Can anyone advise what could be going on here?

In particular, is there anything that happens at compile-time which could affect the ability of the resulting executable to locate libcurl.so or any other resources it needs? My suspicion is that the snap-package containerization of LDC could mean that expectations about system-path locations are interfered with.

Can anyone advise?

Thanks & best wishes,

    -- Joe

Reply via email to