mirror of
https://github.com/golang/go
synced 2024-10-14 20:05:36 +00:00
reflect: fix StructOf GC programs
They are missing a stop byte at the end. Normally this doesn't matter, but when including a GC program in another GC program, we strip the last byte. If that last byte wasn't a stop byte, then we've thrown away part of the program we actually need. Fixes #30606 Change-Id: Ie9604beeb84f7f9442e77d31fe64c374ca132cce Reviewed-on: https://go-review.googlesource.com/c/go/+/165857 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
1650f1ba0b
commit
05b3db24c1
|
@ -2712,6 +2712,7 @@ func StructOf(fields []StructField) Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prog = append(prog, 0)
|
||||||
*(*uint32)(unsafe.Pointer(&prog[0])) = uint32(len(prog) - 4)
|
*(*uint32)(unsafe.Pointer(&prog[0])) = uint32(len(prog) - 4)
|
||||||
typ.kind |= kindGCProg
|
typ.kind |= kindGCProg
|
||||||
typ.gcdata = &prog[0]
|
typ.gcdata = &prog[0]
|
||||||
|
|
20
test/fixedbugs/issue30606.go
Normal file
20
test/fixedbugs/issue30606.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// run
|
||||||
|
|
||||||
|
// Copyright 2019 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 "reflect"
|
||||||
|
|
||||||
|
func main() {}
|
||||||
|
|
||||||
|
func typ(x interface{}) reflect.Type { return reflect.ValueOf(x).Type() }
|
||||||
|
|
||||||
|
var x = reflect.New(reflect.StructOf([]reflect.StructField{
|
||||||
|
{Name: "F5", Type: reflect.StructOf([]reflect.StructField{
|
||||||
|
{Name: "F4", Type: reflect.ArrayOf(5462,
|
||||||
|
reflect.SliceOf(typ(uint64(0))))},
|
||||||
|
})},
|
||||||
|
}))
|
Loading…
Reference in a new issue