6599 – ICE(constfold.c) On use of invalid expression as a compile-time initializer

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6599 - ICE(constfold.c) On use of invalid expression as a compile-time initializer
Summary: ICE(constfold.c) On use of invalid expression as a compile-time initializer
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
Reported: 2011年09月03日 06:54 UTC by Jacob Carlborg
Modified: 2015年06月09日 05:11 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2011年09月03日 06:54:22 UTC
Compiling the following code results in a bus error:
class Orbit
{
 Repository repository = Repository();
}
struct Repository
{
 string fileProtocol = "file://";
 string source = fileProtocol ~ "/usr/local/orbit/repository";
}
void main () {}
DMD 1.069 and 2.054
Mac OS X 10.6.8
GDB session:
(gdb) r 
Starting program: /Users/doob/.dvm/compilers/dmd-1.069/bin/dmd test.d
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x000529b0 in InterfaceDeclaration::~InterfaceDeclaration ()
(gdb) bt
#0 0x000529b0 in InterfaceDeclaration::~InterfaceDeclaration ()
#1 0x000caef8 in TypeTypeof::~TypeTypeof ()
#2 0x000cac0d in TypeTypeof::~TypeTypeof ()
#3 0x000097b8 in StaticIfDeclaration::~StaticIfDeclaration ()
#4 0x0000a930 in StaticIfDeclaration::~StaticIfDeclaration ()
#5 0x00057aee in TemplateParameters::~TemplateParameters ()
#6 0x0002958b in ErrorExp::~ErrorExp ()
#7 0x000b9992 in StructInitializer::~StructInitializer ()
#8 0x000b72d8 in StructInitializer::~StructInitializer ()
#9 0x0000219f in ?? ()
#10 0x000020cd in ?? ()
(gdb)
Comment 1 yebblies 2011年09月05日 21:10:39 UTC
That's a strange place to get the error. I get an AV at constfold.c:1396.
CatExp::optimize calls :optimize on fileProtocol (which does nothing) then passes it along to Cat, which crashes trying to access fileProtocol's type.
It seems to happen for all operators:
class Orbit
{
 Repository repository = Repository();
}
struct Repository
{
 //int source = xx ~ xx;
 //int source = xx + xx;
 //int source = xx - xx;
 //int source = xx * xx;
 //int source = xx / xx;
 //int source = xx ^^ xx;
 //int source = xx & xx;
 int source = xx | xx;
}
void main () {}
It is probably invalid to assume e->type has been set inside Cat and other constfold functions.
Comment 2 Don 2011年09月07日 00:04:01 UTC
(In reply to comment #1)
> That's a strange place to get the error. I get an AV at constfold.c:1396.
> 
> CatExp::optimize calls :optimize on fileProtocol (which does nothing) then
> passes it along to Cat, which crashes trying to access fileProtocol's type.
> 
> It seems to happen for all operators:
[snip] 
> It is probably invalid to assume e->type has been set inside Cat and other
> constfold functions.
No, it's valid. Those functions should only be called after the semantic pass was completed successfully on the expression. This is yet another gagging system bug.
Repository is forward referenced from Orbit. Semantic is run on Repository with errors gagged. This semantic pass fails, but leaves Repository's members in an invalid state.
If you move Orbit after Repository, you see the correct error messages.
Comment 3 yebblies 2011年09月07日 00:32:53 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > That's a strange place to get the error. I get an AV at constfold.c:1396.
> > 
> > CatExp::optimize calls :optimize on fileProtocol (which does nothing) then
> > passes it along to Cat, which crashes trying to access fileProtocol's type.
> > 
> > It seems to happen for all operators:
> [snip] 
> > It is probably invalid to assume e->type has been set inside Cat and other
> > constfold functions.
> 
> No, it's valid. Those functions should only be called after the semantic pass
> was completed successfully on the expression. This is yet another gagging
> system bug.
> 
> Repository is forward referenced from Orbit. Semantic is run on Repository with
> errors gagged. This semantic pass fails, but leaves Repository's members in an
> invalid state.
> If you move Orbit after Repository, you see the correct error messages.
Ok. That would make this another case of bug 4269?
Comment 4 Jacob Carlborg 2011年09月07日 09:26:43 UTC
With DMD 1.069 I get the same error even when I place Repository before Orbit.
Comment 5 Don 2011年09月07日 15:14:47 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > This is yet another gagging system bug.
> > 
> > Repository is forward referenced from Orbit. Semantic is run on Repository with
> > errors gagged. This semantic pass fails, but leaves Repository's members in an
> > invalid state.
> > If you move Orbit after Repository, you see the correct error messages.
> 
> Ok. That would make this another case of bug 4269?
They have the same kind of structural cause in the compiler, but I think they don't have any of the same code in common. It's definitely not a duplicate.


AltStyle によって変換されたページ (->オリジナル) /