-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime.Callers does not include all callers. #29526
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
Comments
Maybe it's just improved inlining (i.e. because See https://github.com/golang/go/wiki/CompilerOptimizations#function-inlining for more info. You can check whether it was actually inlined using |
That sounds very likely, it will make stack traces from https://github.com/pkg/errors look weird though. E.g: main.getFunctionNames /gocode/src/github.com/pkg/errors/errors.go:104 runtime.skipPleaseUseCallersFrames /sdk/go1.12beta1/src/runtime/asm.s:40 main.main /gocode/src/playground/go12beta/main.go:22 runtime.main /sdk/go1.12beta1/src/runtime/proc.go:200 runtime.goexit /sdk/go1.12beta1/src/runtime/asm_amd64.s:1337 Whereas go 1.11.4 produces: main.getFunctionNames /gocode/src/playground/go12beta/main.go:44 main.functionCallingGetFunctionNames /gocode/src/playground/go12beta/main.go:31 main.main /gocode/src/playground/go12beta/main.go:15 runtime.main /usr/local/Cellar/go/1.11.4/libexec/src/runtime/proc.go:201 runtime.goexit /usr/local/Cellar/go/1.11.4/libexec/src/runtime/asm_amd64.s:1333 |
Even if I add logic to the dummy function that prevents inlining, the stack tracing looks incorrect. main.getFunctionNames /gocode/src/github.com/pkg/errors/errors.go:104 runtime.skipPleaseUseCallersFrames /sdk/go1.12beta1/src/runtime/asm.s:40 main.functionCallingGetFunctionNames /gocode/src/playground/go12beta/main.go:32 main.main /gocode/src/playground/go12beta/main.go:16 runtime.main /sdk/go1.12beta1/src/runtime/proc.go:200 runtime.goexit /sdk/go1.12beta1/src/runtime/asm_amd64.s:1337 It still contains skipPleaseUseCallersFrames and it uses the wrong file for main.getFunctionNames. |
As this name suggests, as well as documented in https://golang.org/pkg/runtime/#Callers, please use runtime.CallersFrames (https://golang.org/pkg/runtime/#CallersFrames) instead of FuncForPC over the PCs. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It is not on the latest non-beta release.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/dduJxdG9L1U
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: