www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12044] New: Invalid code gen causes segfault

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

           Summary: Invalid code gen causes segfault
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jcrapuchettes gmail.com



13:40:00 PST ---
The following code example was tested with 2.063.2 and executes without error.
If compiled with 2.064.2 or 2.065.0-b2, the example compiles, but segfaults
when run.

In the example, commenting or changing most of the lines will allow 2.064.2+ to
produce code that does not segfault.

Backtrace output from gdb at point of segfault:
----------------
(gdb) bt



(this=0x7fffffffdad8, fun=...) at valid_sparse.d:42








Example:
----------------
import std.array;
import std.traits;
import std.algorithm;

struct BasicNode(T) { T id; }
struct Hierarchy(Code)
{
    struct Node { Code id; }

    Node[] allNodes;

    bool opEquals(OtherH)(OtherH )
    {
        allNodes.map!("a.id").array;
    }
}

struct Test
{
    void opBinary(string op)(void delegate() fun)
    {
        fun();
    }
}

void main()
{
    Test() in
    {
        enum BlaEnum : ubyte { All }

        auto Blas = [EnumMembers!BlaEnum].map!(a => BasicNode!BlaEnum(a));

        Hierarchy!(BlaEnum) H_T;
    };
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow gmail.com



04:45:14 EET ---
On Win32, it compiles and runs. On Win64 there is a linker error (duplicate
COMDAT).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044




05:02:24 EET ---
The linker error starts appearing after this pull:

https://github.com/D-Programming-Language/phobos/pull/1305

However, that pull likely uncovered the problem rather than introduced a
regression.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044




23:14:56 EET ---
I reran the bisection on Linux/64, where I could reproduce the original
problem. But the bisection identified the same change as the regression:
https://github.com/D-Programming-Language/phobos/pull/1305

I'll try to reduce away the Phobos dependency.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code



01:00:09 EET ---
Reduced test case:

//////////////////////////////////////////
struct S(T)
{
    void f()()
    {
        new T[1];
    }

    bool opEquals(O)(O)
    {
        f();
    }
}

void main()
{
    ()
    {
        enum E { e }
        auto arr = [E.e];
        S!E s;
    }
    ();
}
//////////////////////////////////////////

On Win64, this produces the error:
test.exe.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT
'_D45TypeInfo_AE4test4mainFZv9__lambda1FNaNbNfZv1E6__initZ'

As I suspected, the Phobos change only uncovered a compiler problem.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044


Walter Bright <bugzilla digitalmars.com> changed:

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



01:52:49 PST ---
https://github.com/D-Programming-Language/dmd/pull/3257

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044




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

https://github.com/D-Programming-Language/dmd/commit/6a0618afd2c73dab691ed5d66366ec0529377abf
fix Issue 12044 - Invalid code gen causes segfault

https://github.com/D-Programming-Language/dmd/commit/4529423afa9fdd437415652ebf5f7d436747910c


fix Issue 12044 - Invalid code gen causes segfault

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12044


Kenji Hara <k.hara.pg gmail.com> changed:

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


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