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


--- Comment #0 from thelastmammoth 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: -------
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


--- Comment #1 from Jacob Carlborg <doob me.com> 2012-05-04 14:33:46 PDT ---
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



--- Comment #2 from Jacob Carlborg <doob me.com> 2012-05-05 14:04:01 PDT ---
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



--- Comment #3 from github-bugzilla puremagic.com 2012-05-13 00:34:37 PDT ---
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
Merge pull request #205 from jacob-carlborg/7995

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



--- Comment #4 from thelastmammoth gmail.com 2012-05-23 01:29:13 PDT ---
(In reply to comment #3)
 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
 Merge pull request #205 from jacob-carlborg/7995
 
 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



--- Comment #5 from thelastmammoth gmail.com 2012-05-23 13:58:33 PDT ---
(In reply to comment #4)
 (In reply to comment #3)
 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
 Merge pull request #205 from jacob-carlborg/7995
 
 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



--- Comment #6 from Jacob Carlborg <doob me.com> 2012-05-26 09:15:59 PDT ---
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



--- Comment #7 from dawg dawgfoto.de 2012-06-02 03:32:07 PDT ---
*** 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



--- Comment #8 from github-bugzilla puremagic.com 2012-06-03 10:21:08 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

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

- minimal fix for #7995

https://github.com/D-Programming-Language/druntime/commit/b1433bef8434ba5bdf42d16a1ebbb7153b085b38
Merge pull request #234 from dawgfoto/fix7995

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