-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Description
package main
type T struct {
x int
}
//go:noinline
func (t *T) Foo() int {
return t.x
}
func main() {
(*T)(nil).Foo()
}
When run in go 1.16, we get:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x105e185]
goroutine 1 [running]:
main.(*T).Foo(0x0, 0xc000074058)
/Users/khr/gowork/tmp4.go:9 +0x5
main.main()
/Users/khr/gowork/tmp4.go:13 +0x2a
exit status 2
When run at tip, we get:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10548c0]
goroutine 1 [running]:
main.(*T).Foo(0xc000000180)
/Users/khr/gowork/tmp4.go:9
main.main()
/Users/khr/gowork/tmp4.go:13 +0x1b
exit status 2
Note that the arguments printed for Foo
are not correct. There's only one instead of two arguments. In particular, the thing we got a nil pointer exception on is not listed.
Maybe we're now not printing results, and that's why there's only one? But if that's the case, we're printing the wrong one.
Same problem with
package main
type T struct {
x int
}
//go:noinline
func Foo(t *T) int {
return t.x
}
func main() {
Foo((*T)(nil))
}
So it looks like it isn't specifically due to receivers.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.