digitalmars.D.bugs - [Issue 348] New: string concat in dynamically loaded dll code crashes program
- d-bugmail puremagic.com (36/36) Sep 14 2006 http://d.puremagic.com/issues/show_bug.cgi?id=348
- d-bugmail puremagic.com (8/12) Sep 14 2006 http://d.puremagic.com/issues/show_bug.cgi?id=348
- Sean Kelly (8/22) Sep 14 2006 Given the above code, I think this is to be expected. See this link for...
- d-bugmail puremagic.com (9/9) Jun 25 2008 http://d.puremagic.com/issues/show_bug.cgi?id=348
http://d.puremagic.com/issues/show_bug.cgi?id=348
Summary: string concat in dynamically loaded dll code crashes
program
Product: D
Version: 0.165
Platform: PC
OS/Version: Windows
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: default_357-line yahoo.de
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 ");
}
On gdcwin 0.19, this crashes with a SIGSEGV trying to access 0x0.
The stack trace is:
at dll.d:1
--
Sep 14 2006
http://d.puremagic.com/issues/show_bug.cgi?id=348
Files:
_dll.d_
extern (C) { void test(char[] str) { char[] e=str~"bla"; } }
_test.d_
I forgot to mention two things.
a) dmd generates an access error.
b) Compile the first file into a dll with -Wl,--dll and -shared, and the second
file into an executable normally.
--
Sep 14 2006
d-bugmail 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.
Sep 14 2006
http://d.puremagic.com/issues/show_bug.cgi?id=348
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
Sean is correct. Also, dmd doesn't have flags -Wl,--dll and -shared.
--
Jun 25 2008









d-bugmail puremagic.com 