Commit 13cbf41a authored by Jan Ziak's avatar Jan Ziak

cmd/gc: initialize t->width in dgcsym() if required

Update #5291.

R=golang-dev, daniel.morsing, iant, r
CC=golang-dev
https://golang.org/cl/8663052
parent db1c218d
......@@ -1047,6 +1047,9 @@ dgcsym1(Sym *s, int ot, Type *t, vlong *off, int stack_size)
if(t->align > 0 && (*off % t->align) != 0)
fatal("dgcsym1: invalid initial alignment, %T", t);
if(t->width == BADWIDTH)
dowidth(t);
switch(t->etype) {
case TINT8:
case TUINT8:
......@@ -1141,6 +1144,8 @@ dgcsym1(Sym *s, int ot, Type *t, vlong *off, int stack_size)
case TARRAY:
if(t->bound < -1)
fatal("dgcsym1: invalid bound, %T", t);
if(t->type->width == BADWIDTH)
dowidth(t->type);
if(isslice(t)) {
// NOTE: Any changes here need to be made to reflect.SliceOf as well.
// struct { byte* array; uint32 len; uint32 cap; }
......@@ -1214,6 +1219,9 @@ dgcsym(Type *t)
return s;
s->flags |= SymGcgen;
if(t->width == BADWIDTH)
dowidth(t);
ot = 0;
off = 0;
ot = duintptr(s, ot, t->width);
......
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pkg1
import (
"runtime"
)
type T2 *[]string
type Data struct {
T1 *[]T2
}
func CrashCall() (err error) {
var d Data
for count := 0; count < 10; count++ {
runtime.GC()
len := 2 // crash when >=2
x := make([]T2, len)
d = Data{T1: &x}
for j := 0; j < len; j++ {
y := make([]string, 1)
(*d.T1)[j] = &y
}
}
return nil
}
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"./pkg1"
)
type message struct { // Presence of this creates a crash
data pkg1.Data
}
func main() {
pkg1.CrashCall()
}
// rundir
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 5291: GC crash
package ignored
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment