Thread overview
[Issue 5549] New: [64-bit] Internal error: backend/cgcod.c 1845
Feb 09, 2011
David Simcha
Feb 09, 2011
Don
Feb 10, 2011
Walter Bright
Feb 10, 2011
Walter Bright
February 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5549

           Summary: [64-bit] Internal error: backend/cgcod.c 1845
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dsimcha@yahoo.com


--- Comment #0 from David Simcha <dsimcha@yahoo.com> 2011-02-08 16:55:28 PST ---
This is another insanely hard to reproduce bug.  The following code produces a "Internal error: backend/cgcod.c 1845" only when compiled with -O -inline -release -unittest -m64.  I reduced it as far as I could.  All of the seemingly unnecessary stuff is actually necessary for reproducing this bug.  Also, when I copy/paste the implementation of Map into the same module as the code below, it seems to prevent the bug from being reproduced.

import std.algorithm;

void cleanUp() {}

void doStuff(T)(T data) {
    scope(exit) cleanUp();  // Taking this out gets rid of the bug.
    size_t N = 0;

    foreach(i, rng; data) {  // Taking this loop out gets rid of the bug.
        auto rngLen = rng.length;
        N += rngLen;
    }

    int[] dataArray;
    size_t pos = 0;
    foreach(rng; data) {   // This loop is necessary.
        foreach(elem; rng) {
            dataArray[pos] = elem;
            pos++;
        }
    }

    double rBar = 0.5 * (N + 1);  // Even this line is necessary.
}

void main() {
    // Only happens on instantiations with Map.
    doStuff(
        [map!"a"([3,1,4,1])]
    );
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5549


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2011-02-08 17:08:59 PST ---
(In reply to comment #0)
> This is another insanely hard to reproduce bug.

As (I think) Don has said, back-end bugs are often harder to locate.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5549


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-02-08 23:12:53 PST ---
This sounds quite similar to bug 5455. Both involve register allocation and a complicated and fragile code sequence.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5549


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-02-09 17:56:20 PST ---
https://github.com/D-Programming-Language/dmd/commit/a2b0280ebe1cb40b24c62d199d234bff55bf8024

https://github.com/D-Programming-Language/dmd/commit/8fd6ff07ae7f043e5eff9eb35148f73c54482f96

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5549


Walter Bright <bugzilla@digitalmars.com> changed:

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


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