Bug 7883 – D1: Compiler segfaults with double inheritance and function contract

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2012-04-10T03:14:00Z
Last change time
2013-11-24T20:00:47Z
Keywords
contracts, ice, pull
Assigned to
nobody
Creator
dlang

Attachments

IDFilenameSummaryContent-TypeSize
1087e.dTest case crashing the compilerapplication/octet-stream224

Comments

Comment #0 by dlang — 2012-04-10T03:14:43Z
Created attachment 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;
Comment #1 by dlang — 2012-04-10T03:18:09Z
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
Comment #2 by dlang — 2012-04-10T03:19:46Z
By the way, the test case compiles fine with gdc
Comment #3 by dlang — 2012-04-10T07:06:35Z
Comment on attachment 1087 Test case crashing the compiler This file compiles as it stands; remove the "//" to make it crash dmd.
Comment #4 by lovelydear — 2012-04-21T11:21:34Z
The test case is: 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() { } It compiles and runs on DMD 2.059 Win32
Comment #5 by dlang — 2012-04-21T11:52:23Z
(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() { }
Comment #6 by lovelydear — 2012-04-21T12:13:38Z
(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.
Comment #7 by clugdbug — 2012-05-14T03:16:38Z
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.
Comment #8 by henning — 2013-07-24T12:29:54Z
Comment #9 by github-bugzilla — 2013-07-25T20:01:03Z
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
Comment #10 by k.hara.pg — 2013-07-25T20:08:44Z
Fixed in D2.
Comment #11 by k.hara.pg — 2013-11-24T20:00:47Z
D1 is not supported anymore.