www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: thelastmammoth gmail.com



[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






D4core7runtime7Runtime10initializeFDFC6object9ThrowableZvZb ()



-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 26 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995


thelastmammoth gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P1
                 CC|                            |thelastmammoth gmail.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 26 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995


Jacob Carlborg <doob me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob me.com



I would guess the reason for this is "_d_osx_image_init2" is not called in
"rt_init". "main" should really call "rt_init" do avoid code duplication.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995




Pull request: https://github.com/D-Programming-Language/druntime/pull/205

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 05 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995




Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/714e86fb88459807f35fe7270da592ee06e40e31
Fix issue 7995: D runtime initialization from C fails on OSX in 2.059, worked
in 2.058.

I also refactored the startup code to remove duplicated code.
This will hopefully reduce this kind of bugs in the future.

https://github.com/D-Programming-Language/druntime/commit/6467f87e1a6b4696b9929c459b38477df1cf0522


Fix issue 7995: D runtime initialization from C fails on OSX in 2.059, w...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995





 Commits pushed to master at https://github.com/D-Programming-Language/druntime
 
 https://github.com/D-Programming-Language/druntime/commit/714e86fb88459807f35fe7270da592ee06e40e31
 Fix issue 7995: D runtime initialization from C fails on OSX in 2.059, worked
 in 2.058.
 
 I also refactored the startup code to remove duplicated code.
 This will hopefully reduce this kind of bugs in the future.
 
 https://github.com/D-Programming-Language/druntime/commit/6467f87e1a6b4696b9929c459b38477df1cf0522

 
 Fix issue 7995: D runtime initialization from C fails on OSX in 2.059, w...
Great, thanks, that appears to solve THAT bug, however I filed a new regression bug for a related problem (with dylib instead of lib): see Issue 8133. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995






 Commits pushed to master at https://github.com/D-Programming-Language/druntime
 
 https://github.com/D-Programming-Language/druntime/commit/714e86fb88459807f35fe7270da592ee06e40e31
 Fix issue 7995: D runtime initialization from C fails on OSX in 2.059, worked
 in 2.058.
 
 I also refactored the startup code to remove duplicated code.
 This will hopefully reduce this kind of bugs in the future.
 
 https://github.com/D-Programming-Language/druntime/commit/6467f87e1a6b4696b9929c459b38477df1cf0522

 
 Fix issue 7995: D runtime initialization from C fails on OSX in 2.059, w...
Great, thanks, that appears to solve THAT bug, however I filed a new regression bug for a related problem (with dylib instead of lib): see Issue 8133.
Actually the pull request seems to fix Issue 8133 (but master had reverted it in the meantime). It would be nice to have this pull request back in master ... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995




New pull request:

https://github.com/D-Programming-Language/druntime/pull/228

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 26 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995




*** Issue 8133 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995




Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/f67ac66a0690c5653f027228d71db8a0837f0f0f
fix issue 7995



https://github.com/D-Programming-Language/druntime/commit/b1433bef8434ba5bdf42d16a1ebbb7153b085b38


fix issue 7995

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 03 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7995


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dawg dawgfoto.de
         Resolution|                            |FIXED


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