[Issue 7995] New: regression(2.059): D runtime initialization from C fails on OSX in 2.059, worked in 2.058

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 26 19:24:12 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7995

           Summary: regression(2.059): D runtime initialization from C
                    fails on OSX in 2.059, worked in 2.058
           Product: D
           Version: D2
          Platform: All
        OS/Version: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: thelastmammoth at gmail.com


--- Comment #0 from thelastmammoth at gmail.com 2012-04-26 19:25:16 PDT ---
[note: this was also mentioned in
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=35199
but I didn't see a bug report; I'm also adding that the code worked fine in
2.058 ]

calling D runtime initialization from C fails on OSX in 2.059, but it worked in
2.058. This is a critical bug as it makes it now impossible to call D from C on
OSX.

//main.c
extern void mylib_init();
extern void mylib_free();
int main() {
        mylib_init(); //crashes here
        mylib_free();
        return 0;
}

//mylib.d
module mylib;
import core.runtime;
extern(C) {
        bool mylib_init() { return Runtime.initialize();}        
        bool mylib_free() { return Runtime.terminate();}
}


//Makefile
all:
    dmd -c -lib mylib.d -oflibmylib.a
    gcc -o main main.c -L. -lmylib -L/usr/share/dmd/lib -lphobos2

//output: (through gdb):
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x0000000100009dac in __tls_get_addr ()
(gdb) where
#0  0x0000000100009dac in __tls_get_addr ()
#1  0x0000000100008d80 in thread_attachThis ()
#2  0x0000000100008c3c in thread_init ()
#3  0x000000010000a296 in gc_init ()
#4  0x0000000100010f79 in rt_init ()
#5  0x00000001000075bb in
D4core7runtime7Runtime10initializeFDFC6object9ThrowableZvZb ()
#6  0x0000000100000e5d in mylib_init ()
#7  0x0000000100000e2f in main ()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list