www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10057] New: [2.063 beta] Module info overwritten in shared phobos.

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

           Summary: [2.063 beta] Module info overwritten in shared phobos.
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: mike-wey planet.nl



When running the phobos unittests against the shared phobos libraries, some of
them fail because they are run twice.

This because the Module info from the phobos lib is overwritten by the on from
the binary.

---
module std.c.linux.socket;

import std.stdio;

void main(){}

unittest
{
    writeln("Test");
}
---

When linking with the static phobos:
dmd test.d -unittest -defaultlib=:libphobos2.a

it only prints "Test" once.

While when linking with the shared phobos:
dmd test.d -unittest -defaultlib=:libphobos2so.so

"Test" is printed twice.

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


Walter Bright <bugzilla digitalmars.com> changed:

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



22:28:27 PDT ---
I'm not sure this can be considered a bug in dmd.

What's happening is that you've created two instances of std.c.linux.socket -
one in the shared phobos library, and one in your executable which you are
linking with the shared library.

Which instance 'wins'? It really should be an error, but I don't know how it
could be detected.

I know what you're trying to do - run the unittests against the shared library.
This will never work. It works when linking against a static library because
the unittest module will override everything in the static library. It won't
work with a shared library.

I'm going to mark this as wontfix, as I can't think of a reasonable way to deal
with this, other than "don't do that".

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


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code dawg.eu



Yes, wrong way of doing it and a known issuue. It's the reason why druntime
uses
https://github.com/D-Programming-Language/druntime/blob/master/src/test_runner.d.
I didn't yet got around of updating phobos unittests to use the same mechanism.

 It really should be an error, but I don't know how it
could be detected. It can be detected, because the ModuleInfo* in the shared library points into the executable due to interposing. If we agree that we want to disallow interposing we can make it a runtime error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10057




23:56:19 PDT ---

 It can be detected, because the ModuleInfo* in the shared library points into
 the executable due to interposing. If we agree that we want to disallow
 interposing we can make it a runtime error.
Sounds good to me. Let's do it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10057




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

https://github.com/D-Programming-Language/druntime/commit/5aedb6e292693af18e75215164e9277c879777ce
fix Issue 10057 - Module info overwritten in shared phobos

- detect module collisions by checking that all ModuleInfo* of
  a DSO point into the same segment

- abort the program in that case

- added core.sys.linux.errno to find the name of the executable

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


fix Issue 10057 - Module info overwritten in shared phobos

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


Alex Rønne Petersen <alex lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex lycus.org
         Resolution|WONTFIX                     |FIXED


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