[Issue 4210] Random crashes / heisenbugs caused by dmd commit 478: compiler fucks up vtables

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 19 19:32:46 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4210


nfxjfg at 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 at 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: -------


More information about the Digitalmars-d-bugs mailing list