From: Rémy Oudompheng Date: Sun, 7 Oct 2012 19:46:10 +0000 (+0200) Subject: cmd/gc: more graceful handling of invalid fields in widstruct. X-Git-Tag: go1.1rc2~2212 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=caff4398203582dcdfe400b8b27c9ce218ea4564;p=gostls13.git 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 --- diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c index d9d4df316f..118af7e162 100644 --- a/src/cmd/gc/align.c +++ b/src/cmd/gc/align.c @@ -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; diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h index f6bf8ef8c2..eb2345d6da 100644 --- a/src/cmd/gc/go.h +++ b/src/cmd/gc/go.h @@ -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;