www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4210] New: Random crashes / heisenbugs caused by dmd commit 478

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

           Summary: Random crashes / heisenbugs caused by dmd commit 478
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: patch, wrong-code
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: nfxjfg gmail.com


--- Comment #0 from nfxjfg gmail.com 2010-05-19 15:46:03 PDT ---
This bug report is for dmd 1.061. (Bugzilla doesn't list the newer dmd
versions.)
Older versions are not affected.

Compiling and running a mid-sized project with dmd 1.061, I experience random
segfaults and memory corruption. I have no clue what it causes, I have no test
case, and I don't know how to progress further.

One symptom was that looking up an associative array string key crashed in
Tango's murmur hash routine. Outputting the string showed it was corrupted
(even though I don't know why the string could be successfully printed, but the
hash routine failed.) Another symptom was that taking the address of a virtual
function from a valid, non-null object references yielded a corrupted delegate:
the .funcptr contained something like 0x6xxxxxxx, which is way off the normal
function addresses around 0x8xxxxxx. Which crash exactly happened first changed
as I inserted print calls for debugging.

However, I could track down what change exactly caused this: it's dmd commit
478 (http://dsource.org/projects/dmd/changeset/478). Revision 477 still worked
fine.

Undoing that commit makes it work with dmd 1.061, and I suggest the inverse
patch as the solution.

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


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2010-05-19
17:44:34 PDT ---
changeset 477 fixes other bugs, so rolling it back isn't much of a solution.
Better would be to find what the problem is.

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


nfxjfg gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |
            Summary|Random crashes / heisenbugs |Random crashes / heisenbugs
                   |caused by dmd commit 478    |caused by dmd commit 478:
                   |                            |compiler fucks up vtables


--- Comment #2 from nfxjfg gmail.com 2010-05-19 19:32:43 PDT ---
The offending commit is 478, not 477.

After some hours of messing around, I've actually managed to create a testcase:

template X(alias fn) {
    alias typeof(fn) X;
}

void a()(T1 x) {
    alias X!(T1.foo) P; //line 7

    x.foo();
}

class T1 {
    void foo() {
    }
}

class T2 : T1 {
    void bla() {
        assert(false); //line 19
    }
}

void main() {
    a!()(new T2());
}

The code never calls T2.bla(), only T1.foo(). But the assertion on line 19 is
triggered. The problem is that the compiler generates two vtable entries for
T1.foo, and the second entry is "overwritten" by T2.bla. Thus, when it tries to
call T1.foo by using the second vtable entry, it actually calls T2.bla.

Commenting line 7 makes the problem go away, which hints that the forward
referencing handling is broken. Which doesn't make commit 478 so utterly
unrelated anymore.

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



--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2010-05-20
11:33:14 PDT ---
Thanks for producing this test case, it is most helpful.

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



--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2010-05-23
16:46:08 PDT ---
I cannot reproduce the failure, either with the last release (2.046) or the
current version.

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



--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2010-05-23
16:46:50 PDT ---
Uh, I take that back. It works fine with D2, fails on D1.

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



--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2010-05-23
17:52:06 PDT ---
changeset 498

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


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: -------
May 23 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4210


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aziz.koeksal gmail.com


--- Comment #7 from Don <clugdbug yahoo.com.au> 2010-06-07 04:42:01 PDT ---
*** Issue 4192 has been marked as a duplicate of this issue. ***

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