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

runtime/pprof: incorrect locations for inlined generic functions #64641

Closed
korniltsev opened this issue Dec 11, 2023 · 2 comments
Closed

runtime/pprof: incorrect locations for inlined generic functions #64641

korniltsev opened this issue Dec 11, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@korniltsev
Copy link
Contributor

korniltsev commented Dec 11, 2023

Go version

go version devel go1.22-de5b418bea Sat Dec 2 03:15:03 2023 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/korniltsev/.cache/go-build'
GOENV='/home/korniltsev/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/korniltsev/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/korniltsev/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/korniltsev/github/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/korniltsev/github/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.22-de5b418bea Sat Dec 2 03:15:03 2023 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/korniltsev/github/go/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3732277415=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I produced a pprof profile with the following stacktrace

foo
generic[a,b]
generic[b,a]

And foo and generic[a,b] functions are inlined by the go compiler

Reproducer

More info: #64528 (comment)

What did you expect to see?

I expected to see a pprof Location with 3 Line for this case.

What did you see instead?

Isee a pprof Location with 2 Line for this case. Only

foo
generic[a,b]

and then separate location for

generic[b,a]

I suspect this is because of this line , which checks for function names without generic shapes (generic[...])

if last.Function == newFrame.Function { // maybe recursion.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 11, 2023
@prattmic prattmic added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 11, 2023
@prattmic prattmic added this to the Go1.22 milestone Dec 11, 2023
@prattmic
Copy link
Member

This is #64528 (comment), split into another bug. I think this also qualifies for the backport in #64609.

cc @golang/runtime @cherrymui

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/549135 mentions this issue: runtime/pprof: fix inlined generics locations

ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
When generic function[a,b] is inlined to the same generic function[b,a]
with different types (not recursion) it is expected to get a pprof with
a single Location with two functions. However due to incorrect check
for generics names using runtime.Frame.Function, the profileBuilder
assumes it is a recursion and emits separate Location.

This change fixes the recursion check for generics functions by using
runtime_expandFinalInlineFrame

Fixes golang#64641

Change-Id: I3f58818f08ee322b281daa377fa421555ad328c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/549135
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
korniltsev added a commit to grafana/pyroscope-go that referenced this issue May 21, 2024
korniltsev added a commit to grafana/pyroscope-go that referenced this issue May 22, 2024
* fix(godeltaprof): port fix for golang/go#64528

* fix(godeltaprof): port fix for golang/go#64641

* add go 1.22 for testing
@golang golang locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants