runtime, runtime/trace: EvGoCreate for empty function may lack stack #55116
Labels
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.
Milestone
One of EvGoCreate's arguments is a stack for the called function. When the called function is empty, and it is the last function in the executable (I think), the stack's only frame has a PC of zero and no information. This is caused by this series of events:
runtime.traceGoCreate
calls(*runtime.traceStackTable).put
with the called function's PC andsys.PCQuantum
added to it.(*traceStackTable).dump
, which is responsible for writing resolved stack frames to the trace, usesruntime.CallersFrames
to turn the PCs into frames(*runtime.Frames).Next
callsruntime.findfunc
, which callsruntime.findmoduledatap
.findmoduledatap
contains a loop, searching for the correct module, based on the module'sminpc
andmaxpc
:if datap.minpc <= pc && pc < datap.maxpc { return datap }
- In our case, however,pc
is equal todatap.maxpc
.Looking at an example binary, the last function in it is
On
go baz3
, the EvGoCreate event contains a stack with the PC 46ca60 + 1 (I'm on amd64, where sys.PCQuantum is 1). The last module thatfindmoduledatap
looks at has amaxpc
of 46ca61, which equals our PC.findmoduledatap
returns nil because it couldn't find a matching module, and that bubbles all the way up to(*runtime.Frames).Next
returning an empty runtime.Frame.The text was updated successfully, but these errors were encountered: