Bug 14185 – [ICE] [mtype.c] compiler segfault in in Type::aliasthisOf

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-02-16T00:11:00Z
Last change time
2015-06-17T21:05:05Z
Keywords
accepts-invalid, ice, pull
Assigned to
nobody
Creator
vlevenfeld

Comments

Comment #0 by vlevenfeld — 2015-02-16T00:11:17Z
using DMD git-HEAD /////////////////////////////// CODE: /////////////////////////////// import core.atomic; import core.thread; struct Mutexed (T) { private { T store; shared bool locked; } auto acquire () { return Lock (this); } alias acquire this; struct Lock { this (ref Mutexed source) { this.source = &source; while (cas (&source.locked, false, true)) {} } ~this () { atomicStore (source.locked, false); } ref get () { return source.store; } alias get this; private Mutexed* source; } } void main () { Mutexed!(int[]) x; } /////////////////////////////// BACKTRACE: /////////////////////////////// #0 0x000000000040e2c6 in Type::aliasthisOf (this=0x402054f0) at mtype.c:1267 #1 0x000000000041b3d1 in TypeFunction::callMatch (this=0x3fd8f9c0, tthis=0x0, args=0x40205c80, flag=0) at mtype.c:5901 #2 0x000000000046fd77 in ParamDeduce::fp (this=0x7fffffffa260, fd=0x402061b0) at template.c:2101 #3 0x000000000046fb57 in ParamDeduce::fp (param=0x7fffffffa260, s=0x402061b0) at template.c:2055 #4 0x0000000000544a79 in overloadApply (fstart=0x402061b0, param=0x7fffffffa260, fp=0x46fb01 <ParamDeduce::fp(void*, Dsymbol*)>) at func.c:2798 #5 0x00000000004710a9 in functionResolve (m=0x7fffffffa390, dstart=0x402061b0, loc=..., sc=0x4020f010, tiargs=0x0, tthis=0x40205f30, fargs=0x40205c80) at template.c:2423 #6 0x00000000005452d9 in resolveFuncCall (loc=..., sc=0x4020f010, s=0x402061b0, tiargs=0x0, tthis=0x40205f30, fargs=0x40205c80, flags=0) at func.c:3168 #7 0x000000000051ffc8 in CallExp::semantic (this=0x402134f0, sc=0x4020f010) at expression.c:8456 #8 0x000000000051f8e6 in CallExp::semantic (this=0x40205ca0, sc=0x4020f010) at expression.c:8363 #9 0x000000000045eab1 in ReturnStatement::semantic (this=0x40205cf0, sc=0x4020f010) at statement.c:3729 #10 0x0000000000451aab in CompoundStatement::semantic (this=0x40205d20, sc=0x4020f010) at statement.c:1031 #11 0x000000000053f824 in FuncDeclaration::semantic3 (this=0x40205a30, sc=0x402095f0) at func.c:1534 #12 0x0000000000467111 in AggregateDeclaration::semantic3 (this=0x40205300, sc=0x40209280) at struct.c:235 #13 0x000000000047f167 in TemplateInstance::semantic3 (this=0x7ffff64833b0, sc=0x7fffe91b4a10) at template.c:7344 #14 0x000000000047a87e in TemplateInstance::trySemantic3 (this=0x7ffff64833b0, sc2=0x7fffe91b4a10) at template.c:5641 #15 0x000000000047b894 in TemplateInstance::semantic (this=0x7ffff64833b0, sc=0x7fffe9190610, fargs=0x0) at template.c:6064 #16 0x000000000047a652 in TemplateInstance::semantic (this=0x7ffff64833b0, sc=0x7fffe9190610) at template.c:5582 #17 0x000000000041de22 in TypeInstance::resolve (this=0x7ffff6483580, loc=..., sc=0x7fffe9190610, pe=0x7fffffffbe78, pt=0x7fffffffbe80, ps=0x7fffffffbe70, intypeid=false) at mtype.c:6754 #18 0x000000000041df25 in TypeInstance::semantic (this=0x7ffff6483580, loc=..., sc=0x7fffe9190610) at mtype.c:6776 #19 0x00000000004f3b5e in VarDeclaration::semantic (this=0x7ffff6483660, sc=0x3f339ba0) at declaration.c:854 #20 0x0000000000514899 in DeclarationExp::semantic (this=0x7ffff64837a0, sc=0x3f339ba0) at expression.c:5845 #21 0x0000000000450fa8 in ExpStatement::semantic (this=0x7ffff6483780, sc=0x3f339ba0) at statement.c:826 #22 0x0000000000451aab in CompoundStatement::semantic (this=0x7ffff64837e0, sc=0x3f339ba0) at statement.c:1031 #23 0x000000000053f824 in FuncDeclaration::semantic3 (this=0x7ffff6483160, sc=0x7fffe9008880) at func.c:1534 #24 0x0000000000409679 in Module::semantic3 (this=0x7ffff7ef0910) at module.c:795 #25 0x0000000000405d63 in tryMain (argc=113, argv=0x92bc70) at mars.c:1461 #26 0x000000000040689c in main (argc=109, argv=0x7fffffffd268) at mars.c:1668
Comment #1 by mxfomin — 2015-05-12T10:34:35Z
Reduced import core.atomic; struct Mutexed (T) { auto acquire () { return Lock (this); } alias acquire this; struct Lock { private Mutexed* source; } } void main () { Mutexed!(int[]) x; } Alias does not capture local context, it is not clear what was intended from 'alias acquire this;' but it looks like accepts-invalid.
Comment #2 by mxfomin — 2015-05-12T10:47:05Z
struct Mutexed { auto acquire () { return Lock (this); } alias acquire this; struct Lock { Mutexed* source; } } void main () { Mutexed x; } if auto acquire () is changed to Lock or Lock* acquire() then dmd will emit 'cannot implicitly convert expression (this) of type Mutexed to Mutexed* '. To fix error 'this' argument should be taken by pointer, so it is ice on accepts-invalid.
Comment #3 by mxfomin — 2015-05-12T11:09:08Z
Comment #4 by github-bugzilla — 2015-05-14T01:06:23Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d9a5eedb6f53f7d15e366c0027555eef7c19e706 Fix issue 14185 [ICE] [mtype.c] compiler segfault https://github.com/D-Programming-Language/dmd/commit/9d5cba79ac68f0a6c964b308c6e4bc99b7a3cf6f Merge pull request #4644 from mxfm/fix14185 Fix issue 14185 [ICE] [mtype.c] compiler segfault
Comment #5 by github-bugzilla — 2015-06-17T21:05:05Z