D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7108 - ICE: TraitsExp::semantic(Scope*) 2.056 -> 2.057 regression - segfault
Summary: ICE: TraitsExp::semantic(Scope*) 2.056 -> 2.057 regression - segfault
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 critical
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2011-12-14 04:47 UTC by pelo
Modified: 2011-12-15 00:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description pelo 2011-12-14 04:47:32 UTC
Most of my d code now causes the compiler to core dump.  All 3 of 3 projects no longer work and only two of them share code.

Here's the backtrace I got:

Program terminated with signal 11, Segmentation fault.
#0  0x0000000000520227 in TraitsExp::semantic(Scope*) ()
#1  0x0000000000479f95 in OrOrExp::semantic(Scope*) ()
#2  0x0000000000452729 in StaticIfCondition::include(Scope*, ScopeDsymbol*) ()
#3  0x0000000000407173 in ConditionalDeclaration::include(Scope*, ScopeDsymbol*) ()
#4  0x00000000004065e7 in StaticIfDeclaration::semantic(Scope*) ()
#5  0x0000000000406623 in StaticIfDeclaration::semantic(Scope*) ()
#6  0x0000000000406623 in StaticIfDeclaration::semantic(Scope*) ()
#7  0x00000000004fcd28 in TemplateInstance::semantic(Scope*, ArrayBase<Expression>*)
    ()
#8  0x00000000004c3bba in TypeInstance::resolve(Loc, Scope*, Expression**, Type**, Dsymbol**) ()
#9  0x00000000004b7936 in TypeInstance::toDsymbol(Scope*) ()
#10 0x0000000000453db2 in AliasDeclaration::semantic(Scope*) ()
#11 0x0000000000406623 in StaticIfDeclaration::semantic(Scope*) ()
#12 0x00000000004fcd28 in TemplateInstance::semantic(Scope*, ArrayBase<Expression>*)
    ()
#13 0x0000000000458890 in Dsymbol::searchX(Loc, Scope*, Identifier*) ()
#14 0x00000000004b7a54 in TypeIdentifier::toDsymbol(Scope*) ()
#15 0x0000000000453db2 in AliasDeclaration::semantic(Scope*) ()
#16 0x00000000004fcd28 in TemplateInstance::semantic(Scope*, ArrayBase<Expression>*)
    ()
#17 0x00000000004c3bba in TypeInstance::resolve(Loc, Scope*, Expression**, Type**, Ds
ymbol**) ()

I'll try to narrow down the (multiple) constructs that cause this.
Comment 1 Kenji Hara 2011-12-14 07:14:50 UTC
I found a null dereference bug in TraitsExp::semantic().
Following code kills dmd.

static assert(!__traits(hasMember, int, "x"));

In your environment, can you get similar backtrace?
Comment 2 pelo 2011-12-14 07:23:09 UTC
(In reply to comment #1)
> I found a null dereference bug in TraitsExp::semantic().
> Following code kills dmd.
> 
> static assert(!__traits(hasMember, int, "x"));
> 
> In your environment, can you get similar backtrace?

Yes!  Here is my code:

int main(string argv[]) {
    static assert(! __traits(hasMember, int, "x"));
    return 0;
}

I try to compile:

% dmd yo.d
zsh: segmentation fault (core dumped)  dmd yo.d
Comment 3 pelo 2011-12-14 07:24:29 UTC
Back trace to your simplified case above:

#0  0x0000000000520227 in TraitsExp::semantic(Scope*) ()
(gdb) bt
#0  0x0000000000520227 in TraitsExp::semantic(Scope*) ()
#1  0x000000000047a1aa in NotExp::semantic(Scope*) ()
#2  0x0000000000507115 in StaticAssert::semantic2(Scope*) ()
#3  0x00000000004e4191 in StaticAssertStatement::semantic(Scope*) ()
#4  0x00000000004ef9e4 in CompoundStatement::semantic(Scope*) ()
#5  0x000000000048f7e2 in FuncDeclaration::semantic3(Scope*) ()
#6  0x00000000004b4290 in Module::semantic3() ()
#7  0x000000000040392c in main ()

Could be the same issue.
Comment 4 Kenji Hara 2011-12-14 07:26:35 UTC
Thanks. I'll post a patch to fix it.
Comment 5 pelo 2011-12-14 07:30:41 UTC
(In reply to comment #4)
> Thanks. I'll post a patch to fix it.

Thanks.  I'll test your patch against my code when it's available.