runtime: autogenerated frames not being skipped in CallersFrames #73747
Labels
BugReport
Issues describing a possible bug in the Go implementation.
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
release-blocker
Milestone
Go version
go version go1.25-devel_045b5c1b 2025-05-15 22:00:16 -0700 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Similar issue as #16723 (from 2016).
I'm trying to build a software I work on with gotip, to test an experimental feature, and I noticed many tests around logging were failing.
Looking into it, the root cause is that with some specific code path,
runtime.CallersFrames
unexpectedly returns an autogenerated frame, which makes the logger display the wrong function name for the caller.Here is an example showing this https://go.dev/play/p/9xwoAXbmgCt?v=gotip, you can notice that when using
gotip
the stack trace contains an autogenerated frame (and the log line points to the wrong function), while when using Go 1.24 it's not the case.I tried making a minimal example (in particular without going through the logger dependency), but it seems to only trigger with a very specific combination of structs, embedding, function calls, inlining, etc. For example it doesn't happen with
Warn
,Error
, orCritical
, only withTrace
,Debug
, orInfo
, I believe because the first three also build and return an error, which prevents inlining.What did you see happen?
I use a custom
io.Writer
which displays its stack trace when written to, and we can see that there is an autogenerated frame when running the code in https://go.dev/play/p/9xwoAXbmgCt?v=gotip:With Go 1.24:
What did you expect to see?
Looking at #16723 and https://go-review.googlesource.com/c/go/+/45412, I would say it's a bug in Go as autogenerated stack frames are supposed to be skipped.
The text was updated successfully, but these errors were encountered: