Closed
Description
What version of Go are you using (go version
)?
$ go version go version devel +e9c994954f Sat Oct 19 04:45:10 2019 +0000 darwin/amd64
What did you do?
When running with -gcflags=all=-d=checkptr
against an existing codebase, I saw many panics that seemed to originate from go-cmp. Upon further investigation and minimizing the repro case, I have this near-minimal example:
package main
import (
"fmt"
"reflect"
)
type Foo struct{}
func (Foo) Bar() {}
func main() {
t := reflect.TypeOf(Foo{})
m, ok := t.MethodByName("Bar")
fmt.Println(m, ok)
}
When run with gotip run -gcflags=all=-d=checkptr .
, the following panic occurs:
panic: (runtime.ptrAlign) (0x10e45e0,0xc0000701f0)
goroutine 1 [running]:
reflect.(*funcType).in(...)
/Users/mr/gotip/src/github.com/golang/go/src/reflect/type.go:1011
reflect.funcStr(0xc000090120, 0x10d38c0, 0xc00007aa64)
/Users/mr/gotip/src/github.com/golang/go/src/reflect/type.go:2040 +0x9b4
reflect.FuncOf(0xc0000701e0, 0x1, 0x1, 0x11f4ef0, 0x0, 0x0, 0x100c700, 0x0, 0x0)
/Users/mr/gotip/src/github.com/golang/go/src/reflect/type.go:2023 +0x6d1
reflect.(*rtype).Method(0x10def60, 0x0, 0x10c38db, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/mr/gotip/src/github.com/golang/go/src/reflect/type.go:823 +0x54e
reflect.(*rtype).MethodByName(0x10def60, 0x10fe7b9, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/mr/gotip/src/github.com/golang/go/src/reflect/type.go:845 +0x1a7
main.main()
/tmp/eeee/main.go:14 +0xc0
exit status 2
When run with go version go1.12.9 darwin/amd64
, this program outputs {Bar func(main.Foo) <func(main.Foo) Value> 0} true
.
/cc @mdempsky