I have a (boiled down) very simple program. main calls f calls g. g calls h and indexes into an empty slice using the result of h.
I expect the index out of range stack trace to show the index panic happen in g, called from f, called from main. And it does:
$ cat >x.go <<EOF
package main
type T = [1]byte
var x []T
func main() { f() }
func f() T { return g() }
func g() T { return x[h()] }
func h() int { return 9 }
EOF
$ go run x.go
panic: runtime error: index out of range
goroutine 1 [running]:
main.g(...)
/Users/rsc/x.go:6
main.f(...)
/Users/rsc/x.go:5
main.main()
/Users/rsc/x.go:4 +0x24
exit status 2
$
This is correct.
But now I change the thing being indexed from a slice of 1-bytes to a slice of 2-bytes:
$ sed s/1/2/ x.go >y.go
$ go run y.go
panic: runtime error: index out of range
goroutine 1 [running]:
main.f(...)
/Users/rsc/y.go:5
main.main()
/Users/rsc/y.go:4 +0x24
exit status 2
$
The stack trace no longer shows g. This is not correct.
In the actual program where this came up, my slice was of [32]byte. Changing to slice of int also restores the stack trace. But something about indexing into a slice containing multibyte arrays is breaking the inlined stack trace information for an index panic for that operation.
/cc @randall77 @aclements
I have a (boiled down) very simple program. main calls f calls g. g calls h and indexes into an empty slice using the result of h.
I expect the index out of range stack trace to show the index panic happen in g, called from f, called from main. And it does:
This is correct.
But now I change the thing being indexed from a slice of 1-bytes to a slice of 2-bytes:
The stack trace no longer shows g. This is not correct.
In the actual program where this came up, my slice was of [32]byte. Changing to slice of int also restores the stack trace. But something about indexing into a slice containing multibyte arrays is breaking the inlined stack trace information for an index panic for that operation.
/cc @randall77 @aclements