cmd/gc: more graceful handling of invalid fields in widstruct.

The protection against segfaults does not completely solve
crashes and breaks test/fixedbugs/bug365.go

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6615058
This commit is contained in:
Rémy Oudompheng 2012-10-07 21:46:10 +02:00
parent 54191126e4
commit caff439820
2 changed files with 6 additions and 3 deletions

View File

@ -54,8 +54,11 @@ widstruct(Type *errtype, Type *t, vlong o, int flag)
for(f=t->type; f!=T; f=f->down) {
if(f->etype != TFIELD)
fatal("widstruct: not TFIELD: %lT", f);
if(f->type == T)
break;
if(f->type == T) {
// broken field, just skip it so that other valid fields
// get a width.
continue;
}
dowidth(f->type);
if(f->type->align > maxalign)
maxalign = f->type->align;

View File

@ -146,7 +146,7 @@ struct Type
uchar copyany;
uchar local; // created in this file
uchar deferwidth;
uchar broke;
uchar broke; // broken type definition.
uchar isddd; // TFIELD is ... argument
uchar align;