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 stack for index panic in arg to inlined call #19799

Closed
rsc opened this issue Mar 31, 2017 · 2 comments
Closed

cmd/compile: bad stack for index panic in arg to inlined call #19799

rsc opened this issue Mar 31, 2017 · 2 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Mar 31, 2017

$ cat /tmp/x.go
package main

func f(x int) int {
	return x + 1
}

func main() {
	var v []int
	println("%d\n", f(v[0]))
}
$ go run /tmp/x.go
panic: runtime error: index out of range

goroutine 1 [running]:
main.f(...)
	/tmp/x.go:9
main.main()
	/tmp/x.go:9 +0x11
exit status 2

At first glance I thought the line number was wrong, since main.f and main.main are not both on line 9.

But in fact the bug is that main.f shows up at all. The index panic happens preparing the argument to f, not in the inlined copy of f. The line number is correct - v[0] is on line 9. What's wrong is that main.f shows up at all. It should not.

/cc @davidlazar @aclements

@rsc rsc added this to the Go1.9 milestone Mar 31, 2017
@davidlazar davidlazar self-assigned this Apr 19, 2017
@aclements
Copy link
Member

@davidlazar, do you think you'll have time to look at this soon? If not, no worries, just reassign it to mdempsky (I would take it, but I'll be away from email).

@gopherbot
Copy link

CL https://golang.org/cl/44351 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants