Thread overview
[Issue 11543] New: multiple definition of std.regex with shared library
Nov 18, 2013
Jordi Sayol
Nov 20, 2013
aneas
Nov 20, 2013
aneas
Dec 24, 2013
Martin Nowak
Jan 12, 2014
Walter Bright
Jan 13, 2014
Jordi Sayol
Jan 28, 2014
Martin Nowak
Feb 01, 2014
Martin Nowak
Feb 02, 2014
Martin Nowak
November 18, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11543

           Summary: multiple definition of std.regex with shared library
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: g.sayol@yahoo.es


--- Comment #0 from Jordi Sayol <g.sayol@yahoo.es> 2013-11-18 12:07:11 PST ---
test.d
---
import std.net.curl;

void main()
{
     char[] a = get("http://dlang.org/index.html");
}
---

If liking against phobos shared library, dmd v2.064.2 fails:

$ dmd -L-lcurl -defaultlib=libphobos2.so -run test.d
Fatal Error while loading '/usr/lib/x86_64-linux-gnu/libphobos2.so.0.64':
    The module 'std.regex' is already defined in 'test'.
--- killed by signal 11

No problem if static linking.
No problem with dmd v2.063.2 (static and shared linking).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 20, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11543


aneas <alexander.breckel@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alexander.breckel@gmail.com


--- Comment #1 from aneas <alexander.breckel@gmail.com> 2013-11-20 12:12:55 PST ---
I get a similar error with:

test.d
---
import std.range;

void main()
{
    zip([0]);
}
---

$ dmd -defaultlib=libphobos2.so -run test.d
Fatal Error while loading '/usr/lib/libphobos2.so.0.64':
    The module 'std.range' is already defined in './test'.
Segmentation fault (core dumped)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 20, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11543



--- Comment #2 from aneas <alexander.breckel@gmail.com> 2013-11-20 14:44:50 PST ---
Here is another minimal test case:

main.d
---
import blubb;

void main() {
    f!int();
}
---

blubb.d
---
void f(T)() {
    final switch(false) {
        case true:
    }
}
---

$ dmd -defaultlib= -shared -fPIC -oflibblubb.so blubb.d
$ dmd -defaultlib=libphobos2.so -ofmain main.d -L-lblubb -L-L.
$ LD_LIBRARY_PATH=. ./main
Fatal Error while loading './libblubb.so':
    The module 'blubb' is already defined in './main'.

I couldn't reduce the test case any further. Using a non-final switch or an if-statement does not trigger the error.

Maybe the error message correlates with this:

$ nm main
...
0000000000600f50 B _D5blubb12__ModuleInfoZ
...

whereas an error-free version of main contains no blubb.__ModuleInfo

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 24, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11543



--- Comment #3 from Martin Nowak <code@dawg.eu> 2013-12-24 11:19:55 PST ---
This happens because of copy relocations, i.e. linker generates a copy of the
ModuleInfo symbol in the executable's .bss section.
This causes a false alarm in the druntime code that checks for duplicated
ModuleInfos.
There are two/three ways to fix this.

- Make ModuleInfos immutable, which is something we should do anyhow.
- Avoid references to foreign ModuleInfos, a bit more complex but necessary
  for https://github.com/D-Programming-Language/dmd/pull/2561.
- Adapt the druntime code to detect this false error. Somewhat dirty hack.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 12, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11543


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2014-01-12 13:12:35 PST ---
Is this really a regression? I don't think we had shared library support before 2.064.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11543


Jordi Sayol <g.sayol@yahoo.es> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |major


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 28, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11543


Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3
         AssignedTo|nobody@puremagic.com        |code@dawg.eu
           Severity|major                       |critical


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11543



--- Comment #5 from Martin Nowak <code@dawg.eu> 2014-02-01 12:43:00 PST ---
As an intermediate workaround, it seems that this issue doesn't occur when building optimized binaries (-release -O -inline).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 02, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11543



--- Comment #6 from Martin Nowak <code@dawg.eu> 2014-02-01 16:12:28 PST ---
Only -release is needed.
I think that is because non-release build reference other ModuleInfos for
assert and bounds-checking, (see
https://github.com/D-Programming-Language/dmd/pull/2561).
Anyhow we should still make ModuleInfo read-only.

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