Bug 4611 – stack overflow or ICE(cgcod.c) when static array of structs exceeds 16MB limit

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-10T07:22:00Z
Last change time
2015-06-09T05:11:54Z
Keywords
ice, wrong-code
Assigned to
nobody
Creator
hoganmeier

Comments

Comment #0 by hoganmeier — 2010-08-10T07:22:54Z
void main() { const int w = 1024, h = 768; Vec[w*h] a; } struct Vec { double x,y,z; } This doesn't yield an error message, it just crashes with Stack Overflow. The following patch also works in the forward reference case shown above. I wonder why class was in that list but not struct: Index: G:/dmd/src/dmd/mtype.c =================================================================== --- G:/dmd/src/dmd/mtype.c (revision 608) +++ G:/dmd/src/dmd/mtype.c (working copy) @@ -3351,6 +3351,7 @@ tbn->ty == Tarray || tbn->ty == Tsarray || tbn->ty == Taarray || + tbn->ty == Tstruct || tbn->ty == Tclass) { /* Only do this for types that don't need to have semantic() * run on them for the size, since they may be forward referenced. */
Comment #1 by hoganmeier — 2010-08-10T07:31:31Z
Never mind, class is in that list because size() simply returns PTRSIZE. So the question is if there are any forward reference cases where this patch fails because of unsigned AggregateDeclaration::size(Loc loc) { //printf("AggregateDeclaration::size() = %d\n", structsize); if (!members) error(loc, "unknown size"); if (sizeok != 1 && scope) semantic(NULL); if (sizeok != 1) { error(loc, "no size yet for forward reference"); //*(char*)0=0; } return structsize; }
Comment #2 by clugdbug — 2010-12-05T23:45:50Z
This variation is ICE(cgcod.c): struct Vec { int x; } void main() { Vec[1000_000_000] a; }
Comment #3 by bugzilla — 2013-10-03T19:15:36Z
Comment #4 by github-bugzilla — 2013-10-05T19:15:09Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/53645e4508880df0bf6ce0fd78c5596e075dddb4 fix Issue 4611 - stack overflow or ICE(cgcod.c) when static array of structs exceeds 16MB limit https://github.com/D-Programming-Language/dmd/commit/3e87ccdd4db2e4581b799af728ed36f58dcd29c1 Merge pull request #2624 from WalterBright/fix4611 fix Issue 4611 - stack overflow or ICE(cgcod.c) when static array of str...
Comment #5 by github-bugzilla — 2013-10-05T20:08:46Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/5e9152194f589d2e3556d87e99edb9865bdab6dd Merge pull request #2624 from WalterBright/fix4611 fix Issue 4611 - stack overflow or ICE(cgcod.c) when static array of str...