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

Incorrect stack tracing of morestack_noctx function on linux/arm64 #3122

Closed
erifan opened this issue Aug 25, 2022 · 1 comment
Closed

Incorrect stack tracing of morestack_noctx function on linux/arm64 #3122

erifan opened this issue Aug 25, 2022 · 1 comment

Comments

@erifan
Copy link

erifan commented Aug 25, 2022

1, What version of Delve are you using (dlv version)?
Delve Debugger
Version: 1.9.1
Build: $Id: d81b9fd12bfa603f3cf7a4bc842398bd61c42940 $

2, What version of Go are you using? (go version)?
go version devel go1.20-75cdd2c75d Wed Aug 24 02:54:32 2022 +0000 linux/arm64

3, What operating system and processor architecture are you using?
linux arm64, kernel version: 5.15.52-051552-generic-64k

4, What did you do?
$ cat main.go

`package main

import(
"fmt"
)

func foo(a, b string) string {
var arr [10000]string
for i := 0; i < 10000; i++ {
arr[i] = a + b
}
return arr[90]
}

func main() {
s := ""
for i := 0; i < 1000; i++ {
s += foo("a", "b")
}
fmt.Println(s)
}
`

$ go build -o main main.go
$ dlv exec ./main
$ b morestack_noctxt
$ c
$ bt

5, What did you expect to see?
Normal stack tracing info

6, What did you see instead?
0 0x0000000000069d10 in runtime.morestack_noctxt
at ./go-master/src/runtime/asm_arm64.s:323
1 0x0000000000058ff0 in runtime.concatstring2
at :0
2 0x0000000000058ff0 in runtime.concatstring2
at :0
3 0x0000000000058ff0 in runtime.concatstring2
at :0
4 0x0000000000058ff0 in runtime.concatstring2
at :0
5 0x0000000000058ff0 in runtime.concatstring2
at :0
6 0x0000000000058ff0 in runtime.concatstring2
at :0
7 0x0000000000058ff0 in runtime.concatstring2
at :0
8 0x0000000000058ff0 in runtime.concatstring2
at :0
9 0x0000000000058ff0 in runtime.concatstring2
at :0
10 0x0000000000058ff0 in runtime.concatstring2
at :0
11 0x0000000000058ff0 in runtime.concatstring2
at :0
12 0x0000000000058ff0 in runtime.concatstring2
at :0
13 0x0000000000058ff0 in runtime.concatstring2
at :0
14 0x0000000000058ff0 in runtime.concatstring2
at :0
Sending output to pager...
0 0x0000000000069d10 in runtime.morestack_noctxt
at ./go-master/src/runtime/asm_arm64.s:323
1 0x0000000000058ff0 in runtime.concatstring2
at :0
2 0x0000000000058ff0 in runtime.concatstring2
at :0
3 0x0000000000058ff0 in runtime.concatstring2
at :0
4 0x0000000000058ff0 in runtime.concatstring2
at :0
5 0x0000000000058ff0 in runtime.concatstring2
at :0
6 0x0000000000058ff0 in runtime.concatstring2
at :0
7 0x0000000000058ff0 in runtime.concatstring2
at :0
8 0x0000000000058ff0 in runtime.concatstring2
at :0
9 0x0000000000058ff0 in runtime.concatstring2
at :0
10 0x0000000000058ff0 in runtime.concatstring2
at :0
11 0x0000000000058ff0 in runtime.concatstring2
at :0

@aarzilli
Copy link
Member

aarzilli commented Sep 1, 2022

I don't think we should fix this. It is related to golang/go#54332 which is caused by the compiler emitting bad unwind information for that function. Adding a workaround specifically for runtime.morestack_noctxt to delve is easy but you will have the same problem for runtime.morestack only much more complicated because that function actually performs a stack switch.

In general all functions that perform a stack switch have places where stacktraces end up being wrong. The format of debug_frame is very flexible so in theory it would be possible to fix this but it would involve a lot of effort and it would have to be done in the compiler, not as a series of workarounds in the debugger.

Thus, I'm closing this as "won't fix". However if you believe that this function in particular deserves a workaround more than any other function that suffers from the same problem, please explain why and I will reconsider.

@aarzilli aarzilli closed this as completed Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants