www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6108] New: Crash on inherited contract using overridden method in unittest

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
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

Cannot access memory at address 0x8




D4core7runtime18runModuleUnitTestsUZb16__foreachbody255MFKPS6object10ModuleInfoZi
()





---

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: -------
Jun 05 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6108


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |DUPLICATE



13:41:45 PST ---
*** This issue has been marked as a duplicate of issue 7335 ***

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