Bug 12190 – runtime loaded shared library on osx: partially worked in 2.062, fails since 2.063

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Mac OS X
Creation time
2014-02-18T00:44:37Z
Last change time
2024-12-13T18:16:58Z
Keywords
dll
Assigned to
No Owner
Creator
Timothee Cour
Moved to GitHub: dmd#18774 →

Comments

Comment #0 by timothee.cour2 — 2014-02-18T00:44:37Z
Now that issue 11478 is partially fixed (linktime shared libraries), on to runtime loaded shared libraries: ---- module foo; import std.stdio; extern(C) void foo1(){ printf("ok1\n"); import core.runtime; bool ret=Runtime.initialize(); //is it necessary? printf("ret=%d\n",ret); printf("ok2\n"); writeln("ok3"); int[]a; a.length=2; //ok writeln(a.length); //dmd2.062 only crashes at this point } ---- module main2; import std.stdio, core.sys.posix.dlfcn; void main(){ string file="libfoo.dylib"; auto handle = dlopen(file.ptr, RTLD_LAZY | RTLD_GLOBAL); auto funptr = cast(void function()) dlsym(handle, "foo1"); funptr(); } ---- dmd -oflibfoo.dylib -shared foo.d; dmd main.d ./main --output: 2.062: crashes at writeln(a.length) (lldb shows it crashes inside LockingTextWriter), which can still be useful for writing plugins. git head: crashes upon loading Also, note that dlopen() of a D shared library works when called from a C++ file, and that a C++ file can call multiple D shared libraries simultaneously when using RTLD_LAZY option. Before waiting for a full solution with an integrated druntime, is there at least a way to have a separate runtime in each shared library, so that dlopen() can be called from a D file?
Comment #1 by bugzilla — 2014-06-20T20:52:41Z
It appears from the text here that this is not a regression since it never did work. Reclassified.
Comment #2 by robert.schadek — 2024-12-13T18:16:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18774 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB