[Issue 348] New: string concat in dynamically loaded dll code crashes program

Sean Kelly sean at f4.ca
Thu Sep 14 15:44:52 PDT 2006


d-bugmail at puremagic.com wrote:
> 
> A string concat in a dynamically loaded C linkage function crashes the program
> with a SIGSEGV in _d_new (wtf)
> Files:
> _dll.d_
> extern (C) { void test(char[] str) { char[] e=str~"bla"; } }
> _test.d_
> import std.c.windows.windows;
> 
> void main() {
>   auto func=cast(void function(char[])) GetProcAddress(LoadLibraryA("dll.dll"),
> "test");
>   func("Bla bla bla ");
> }

Given the above code, I think this is to be expected.  See this link for 
a description of what must be done to produce a dynamic library in D:

http://www.digitalmars.com/d/dll.html

Basically, you must initialize the D compiler runtime, the garbage 
collector, and call module ctors when the library is loaded.  The 
current method for doing this kind of stinks, but it wouldn't be 
terribly difficult to improve.



More information about the Digitalmars-d-bugs mailing list