www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7883] New: Compiler crashes with double inheritance and function contract

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

           Summary: Compiler crashes with double inheritance and function
                    contract
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dlang grotmol.net



---
Created an attachment (id=1087)
Test case crashing the compiler

Class C inherits from B which inherits from A. All three classes define the
same function. A and B specifies an out contract on the function (C may or may
not specify an out contract, it doesn't matter). In this case, dmd crashes
without error message, and doesn't generate the .exe file.

Here is the verbose output:
$ dmd -v e
binary    C:\D\dmd2\windows\bin\dmd.exe
version   v2.058
config    C:\D\dmd2\windows\bin\sc.ini
parse     e
importall e
import    object       
(C:\D\dmd2\windows\bin\..\..\src\druntime\import\object.di)
semantic  e
semantic2 e
semantic3 e

At this point it just stops. The rest of the output should have been as
follows, if I remove one of the two contracts:
code      e
function  e.A.foo
function  e.A.foo.__ensure
function  e.B.foo
function  e.C.foo
function  D main
C:\D\dmd2\windows\bin\link.exe e,,nul,user32+kernel32/noi;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883




---
Note the attached file has commented out one of the contracts and thus
compiles; remove the "//" and the crash arises.

Here is the Windows 7 crash information:

Problem signature:
  Problem Event Name:    APPCRASH
  Application Name:    dmd.exe
  Application Version:    0.0.0.0
  Application Timestamp:    00000000
  Fault Module Name:    dmd.exe
  Fault Module Version:    0.0.0.0
  Fault Module Timestamp:    00000000
  Exception Code:    c0000005
  Exception Offset:    0004d784
  OS Version:    6.1.7601.2.1.0.256.48
  Locale ID:    1044
  Additional Information 1:    c0d2
  Additional Information 2:    c0d2fd7c47233db608dcc0a8dfa7e295
  Additional Information 3:    77a4
  Additional Information 4:    77a4546d10565e53c3340bd335ee63b4

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883




---
By the way, the test case compiles fine with gdc

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883




---
(From update of attachment 1087)
This file compiles as it stands; remove the "//" to make it crash dmd.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883




---

 It compiles and runs on DMD 2.059 Win32
Hi, Could you check this one also please? By mistake the file I uploaded had commented out one of the contracts, and then the file does indeed work. It is only when both contracts are in place, that dmd crashes. class A { int foo(int i) out (result) { } body { return 1; } } class B : A { int foo(int i) out (result) { } body { return 1; } } class C : B { int foo(int i) { return 1; } } void main() { } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883




PDT ---


 It compiles and runs on DMD 2.059 Win32
Hi, Could you check this one also please? By mistake the file I uploaded had commented out one of the contracts, and then the file does indeed work. It is only when both contracts are in place, that dmd crashes.
Yes, it crashes DMD Win32 here too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |clugdbug yahoo.com.au
            Version|D2                          |D1 & D2
            Summary|Compiler crashes with       |Compiler segfaults with
                   |double inheritance and      |double inheritance and
                   |function contract           |function contract
         OS/Version|Windows                     |All



Also crashes on D1 Linux.

It's in func.c(1987), in FuncDeclaration::mergeFensure(Statement * sf)

fensure is NULL (In fact, it's called with fensure = mergeFensure(fensure)

            if (sf)
            {
                sf = new CompoundStatement(fensure->loc, s2, sf);
            }

Changing this to sf->loc prevents the segfault. But, there's something else
wrong -- after this change, it prints

bug.d(21): Error: undefined identifier result

whereas it should compile without error.

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


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |henning still-hidden.de



PDT ---
https://github.com/D-Programming-Language/dmd/pull/2379

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 24 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ba2caff1a4819fecd36954a627f07019ec5ff99c
fix issue 7883 - Compiler segfaults with double inheritance and function
contract

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


fix issue 7883 - Compiler segfaults with double inheritance and function
contract

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 25 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7883


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D1
            Summary|Compiler segfaults with     |(D1 only) Compiler
                   |double inheritance and      |segfaults with double
                   |function contract           |inheritance and function
                   |                            |contract



---
Fixed in D2.

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