Skip to content

reflect: ptrAlign panic when accessing Method #35002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mark-rushakoff opened this issue Oct 19, 2019 · 2 comments
Closed

reflect: ptrAlign panic when accessing Method #35002

mark-rushakoff opened this issue Oct 19, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@mark-rushakoff
Copy link
Contributor

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

@mdempsky
Copy link
Contributor

Thanks, this is a known issue. In general, the standard library still has a few issues with -d=checkptr (see #34972).

For this issue in particular, I have a fix at https://go-review.googlesource.com/c/go/+/201839 if you want to try that.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 21, 2019
@mdempsky
Copy link
Contributor

This should be fixed now.

@golang golang locked and limited conversation to collaborators Oct 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants