Skip to content
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

cmd/compile: bad traceback arguments #45728

Open
randall77 opened this issue Apr 23, 2021 · 1 comment
Open

cmd/compile: bad traceback arguments #45728

randall77 opened this issue Apr 23, 2021 · 1 comment
Milestone

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Apr 23, 2021

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.

@cherrymui @dr2chase @thanm

@randall77 randall77 added this to the Go1.17 milestone Apr 23, 2021
@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Apr 23, 2021

Yes, we are not printing results now.

Yes, the argument is wrong if it is never spilled to memory. Currently we are just printing the memory content. There are pending works that tracks whether the memory slot is accurate. For the moment I don't think we will print register values. At least, panic message says addr=0x0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants