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


--- Comment #0 from Řyvind Grotmol <dlang grotmol.net> 2012-04-10 03:14:43 PDT
---
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



--- Comment #1 from Řyvind Grotmol <dlang grotmol.net> 2012-04-10 03:18:09 PDT
---
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



--- Comment #2 from Řyvind Grotmol <dlang grotmol.net> 2012-04-10 03:19:46 PDT
---
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



--- Comment #3 from Řyvind Grotmol <dlang grotmol.net> 2012-04-10 07:06:35 PDT
---
(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



--- Comment #5 from Řyvind Grotmol <dlang grotmol.net> 2012-04-21 11:52:23 PDT
---
(In reply to comment #4)
 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



--- Comment #6 from SomeDude <lovelydear mailmetrash.com> 2012-04-21 12:13:38
PDT ---
(In reply to comment #5)
 (In reply to comment #4)
 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


--- Comment #7 from Don <clugdbug yahoo.com.au> 2012-05-14 03:16:38 PDT ---
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


--- Comment #8 from Henning Pohl <henning still-hidden.de> 2013-07-24 12:29:54
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



--- Comment #9 from github-bugzilla puremagic.com 2013-07-25 20:01:03 PDT ---
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
Merge pull request #2379 from hpohl/7883

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


--- Comment #10 from Kenji Hara <k.hara.pg gmail.com> 2013-07-25 20:08:44 PDT
---
Fixed in D2.

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