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

rsc opened this issue Mar 31, 2017 · 2 comments


None yet
4 participants
Copy link

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]:
	/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


This comment has been minimized.

Copy link

commented May 27, 2017

@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).


This comment has been minimized.

Copy link

commented May 27, 2017

CL mentions this issue.

@gopherbot gopherbot closed this in b928e2f Jun 2, 2017

@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.
You can’t perform that action at this time.