www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6012] New: DMD version 1.064 and above causes segfaults in C libraries

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6012

           Summary: DMD version 1.064 and above causes segfaults in C
                    libraries
           Product: D
           Version: D1
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: wallbraker gmail.com


--- Comment #0 from Jakob Bornecrantz <wallbraker gmail.com> 2011-05-15
17:04:55 PDT ---
A program that works perfectly fine with DMD versions 1.063 and below as well
as GDC stops working with DMD 1.064.

Disassembling the code showed that the code was exactly the same in the calling
D function for both versions of the compiler. I tried to create a small example
but  failed.

Just working around the offending code caused failures in other calls to C
libraries, tested the same code with DMD 1.063 and that worked with the
workarounds still in place.

If I knew which git commits responds to each version I could do a bisect of the
compiler.

Cheers Jakob.

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


Jakob Bornecrantz <wallbraker gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|DMD                         |Phobos
            Summary|DMD version 1.064 and above |Phobos version 1.064 and
                   |causes segfaults in C       |above causes segfaults in C
                   |libraries                   |libraries


--- Comment #1 from Jakob Bornecrantz <wallbraker gmail.com> 2011-05-15
18:22:55 PDT ---
So I built what I think where 3 different versions of the dmd D1 compiler from
the git repository:

1.063   960cfede4f63e1a730a11464827b70ecd714aaf4
1.064   03309e5c0f05d7e599e847b2d89aa2a93a426304
1.065   8fb6d9a935b7b51ca6caf8e26c94125fc317b434

All of these worked when I just dropped them into linux/bin/ of the dmd.1.063
release, this makes me believe that this is strangely enough a phobos issue.

Cheers Jakob.

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


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com


--- Comment #2 from Jonathan M Davis <jmdavisProg gmx.com> 2011-05-15 18:41:31
PDT ---
You're going to need to give more information than that. There isn't enough
information here for anyone to even begin to look at the problem. You need to
provide code samples.

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


Jakob Bornecrantz <wallbraker gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #3 from Jakob Bornecrantz <wallbraker gmail.com> 2011-05-15
19:15:09 PDT ---
Ugh sorry for wasting your time. This is mostly my fault, it turns out that dmd
1.064 added "-L--export-dynamic" to DFLAGS.

Say a library Bar have a function called barFunc, now my bindings to the C
libraries looked something like this:

extern (C) void (*barFunc)();

Which I then loaded with a library loader functions for that platform.

Now lets say library Foo is linked in and it uses function barFunc. The binding
function in my program gets the symbol name _barFunc since its declared with
extern(C). This worked in the past as none of those functions where exported by
default, but when DMD 1.064 added "-L--export-dynamic" those pointers got
exported. And they get resolved before any of the other normal functions
causing the callee from Foo to jump to the pointer instead of the real
function.

Either I just remove the "-L--export-dynamic" from dmd.conf or change the
bindings to be this instead:

typedef extern (C) void function() pfn_BARFUNC;

pfn_BARFUNC barFunc;

Now barFunc gets a prober D symbol and things works again.

Cheers Jakob.

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



--- Comment #4 from Jakob Bornecrantz <wallbraker gmail.com> 2011-05-15
19:16:15 PDT ---
Forgot to add that I tested with DMD 1.068 both 32 and 64 bits and it works if
I remove the flag, and does not work if its still there.

Cheers Jakob.

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