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

           Summary: Crash on inherited contract using overridden method in
                    unittest
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: c...@klickverbot.at


--- Comment #0 from klickverbot <c...@klickverbot.at> 2011-06-05 08:29:41 PDT 
---
Consider the following piece of code:
---
class A {
  bool isOpen() {
    return false;
  }

  void read() in {
    assert(isOpen);
  } body {}
}

class B : A {
  override bool isOpen() {
    return foo_;
  }

  override void read() {}

  bool foo_ = true;
}

void main() {}

unittest {
  auto b = new B;
  b.read();
}
---

Running the unittest with latest DMD (0ba8f0d) on OS X gives:
---
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000008
0x00000008 in ?? ()
(gdb) bt
#0  0x00000008 in ?? ()
Cannot access memory at address 0x8
#1  0x00001a0a in D4test1B4readMFZv ()
#2  0x00001a36 in D4test11__unittest1FZv ()
#3  0x00001973 in _D4test9__modtestFZv ()
#4  0x00008be9 in
D4core7runtime18runModuleUnitTestsUZb16__foreachbody255MFKPS6object10ModuleInfoZi
()
#5  0x00003f9b in D6object10ModuleInfo7opApplyFMDFKPS6object10ModuleInfoZiZi ()
#6  0x00008ada in runModuleUnitTests ()
#7  0x0001232e in D2rt6dmain24mainUiPPaZi6runAllMFZv ()
#8  0x00011ea5 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
#9  0x00011e3f in main ()
---

Some observations:
 - The segfault occurs in the read() in contract.
 - It only occurs if the code is run in an unittest block.
 - The problem seems to be accessing foo_ – if I change B.isOpen to »return
true;«, it works fine.

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

Reply via email to