Bug 10074 – segfault in dmd

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-13T05:15:00Z
Last change time
2013-11-21T18:42:16Z
Keywords
ice, pull
Assigned to
nobody
Creator
jens.k.mueller

Comments

Comment #0 by jens.k.mueller — 2013-05-13T05:15:50Z
The following program causes dmd (dmd2.062) to segfault on Linux. template foo(F) { enum foo = false; } bool foo(F)(F f) if (foo!F) { return false; } void main() { foo(1); } $ dmd test.d segmentation fault dmd test.d I expect the program to compile or abort with an error but there should be no segfault.
Comment #1 by bugzilla — 2013-10-01T20:16:59Z
It's actually a stack overflow, endlessly repeating: #61 0x080ba021 in ScopeExp::semantic (this=0x9fa2ee8, sc=0x9fa2f08) at expression.c:5018 #62 0x0817d987 in TemplateDeclaration::matchWithInstance (this=0x8294908, sc=0x9fa2978, ti=0x9fa2858, dedtypes=0xff5ffa5c, fargs=0x0, flag=0) at template.c:928 #63 0x0818ad2e in TemplateInstance::ParamNeedsInf::fp (this=0xff5ffa50, s=0x8294908) at template.c:6522 #64 0x0818a95d in TemplateInstance::ParamNeedsInf::fp (param=0xff5ffa50, s=0x8294908) at template.c:6434 #65 0x080e6807 in overloadApply (fstart=0x8294428, param=0xff5ffa50, fp=0x818a945 <TemplateInstance::ParamNeedsInf::fp(void*, Dsymbol*)>) at func.c:2446 #66 0x0818ae6b in TemplateInstance::needsTypeInference (this=0x9fa2858, sc=0x9fa2978, flag=0) at template.c:6548
Comment #2 by bugzilla — 2013-10-01T20:50:09Z
It's looking at the constraint: if (foo!F) recursively in attempting to see if the template instantiation needs type inference.
Comment #3 by k.hara.pg — 2013-10-01T22:32:44Z
This is a regression issue from 2.061. https://github.com/D-Programming-Language/dmd/pull/2613
Comment #4 by github-bugzilla — 2013-10-02T10:07:48Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/209c0d4f6b058472559d9ed3b8076bddf1e2c1e5 fix Issue 10074 - segfault in dmd From 2.061, `deduceFunctionTemplate` has been using TemplateDeclaration::matchWithInstance to do IFTI more strictly. However, `matchWithInstance` does not detect the recursive template instantiation inside template constraint, against `deduceFunctionTemplateMatch`. Duplicate the detection mechanism into `matchWithInstance`. https://github.com/D-Programming-Language/dmd/commit/457acb1e03257fbff3ad52477d44d0d08ebb2d3e Merge pull request #2613 from 9rnsr/fix10074 [REG2.061] Issue 10074 - segfault in dmd
Comment #5 by k.hara.pg — 2013-10-10T23:19:51Z
*** Issue 11067 has been marked as a duplicate of this issue. ***
Comment #6 by k.hara.pg — 2013-11-15T00:47:11Z
*** Issue 11090 has been marked as a duplicate of this issue. ***
Comment #7 by k.hara.pg — 2013-11-21T18:42:16Z
*** Issue 8344 has been marked as a duplicate of this issue. ***