https://issues.dlang.org/show_bug.cgi?id=17591
Issue ID: 17591 Summary: SIGSEGV in pthread_mutex_destroy after dlopen'ing a shared library with -defaultlib=libphobos2.so Product: D Version: D2 Hardware: x86 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: timothee.co...@gmail.com another take at https://issues.dlang.org/show_bug.cgi?id=17588: ``` dmd -of$lib_F -shared -fPIC mylib.d -defaultlib=libphobos2.so dmd -of$out_F main.d $out_F Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7bc36b1 in pthread_mutex_destroy () from /lib/x86_64-linux-gnu/libpthread.so.0 #0 0x00007ffff7bc36b1 in pthread_mutex_destroy () from /lib/x86_64-linux-gnu/libpthread.so.0 #1 0x00000000004555da in _d_critical_term () #2 0x00000000004447e8 in rt_term () #3 0x000000000043c82e in _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFNlZv () #4 0x000000000043c7a4 in _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFNlMDFZvZv () #5 0x000000000043c714 in _d_run_main () #6 0x000000000043b82e in main () #7 0x00007ffff6ee8830 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6 #8 0x000000000043ab39 in _start () ``` with: ``` mylib.d: {} main.d: void main(){ string file=`libfoo`; import core.sys.posix.dlfcn; import std.string:toStringz; auto flag=RTLD_LAZY | RTLD_LOCAL; auto handle=dlopen(file.toStringz, flag); assert(handle); int ret=dlclose(handle); assert(!ret); import std.stdio; writeln("ok"); // segfaults before process finishes } ``` NOTE: if I replace -defaultlib=libphobos2.so with -defaultlib=libphobos2.a it works, but I'd like to use -defaultlib=libphobos2.so (my use case is more complex and mylib.d itself links against other libs that use libphobos.so) --