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

cmd/pprof: use $GOPATH for source file lookup #23376

Open
phemmer opened this issue Jan 8, 2018 · 7 comments
Open

cmd/pprof: use $GOPATH for source file lookup #23376

phemmer opened this issue Jan 8, 2018 · 7 comments
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

Comments

@phemmer
Copy link

phemmer commented Jan 8, 2018

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN="/Users/phemmer/.go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/phemmer/.go:/tmp/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/go-build517300090=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Attempted to profile a heap dump from a binary built on another host and use list foo

What did you expect to see?

The source code with corresponding data for each line.

What did you see instead?

(pprof) list unmarshalBinary
Total: 1.95GB
ROUTINE ======================== github.com/influxdata/kapacitor/vendor/github.com/influxdata/influxdb/models.(*point).unmarshalBinary in /root/go/src/github.com/influxdata/kapacitor/vendor/github.com/influxdata/influxdb/models/points.go
    1.49GB     1.49GB (flat, cum) 76.51% of Total
 Error: open /root/go/src/github.com/influxdata/kapacitor/vendor/github.com/influxdata/influxdb/models/points.go: no such file or directory

On my local system, this source code can instead be found in /Users/phemmer/.go/....

Ref #13231 which is related, but I can't use $GOROOT, as I don't have a full go toolkit in my home directory, only application source.

@ianlancetaylor
Copy link
Contributor

CC @matloob @rauls5382

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 8, 2018
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jan 8, 2018
@constant-null
Copy link

constant-null commented Mar 13, 2018

Have similar issue, i have binaries built by CI where $GOPATH set to /go.
When we get profile file from remote host and try to use it locally with different GOPATH set, the described error occurs.

It is possible to create simlink ($GOPATH -> /go), to trick pprof so it start working correctly, but it is requiring root privileges and not very convenient.

@ardan-bkennedy
Copy link

I just ran into this issue today in class :(. Is there any other solution?

@rauls5382
Copy link
Contributor

FWIW this was fixed in upstream pprof by using heuristics to automatically trim the paths in the profiles, and adding a new trim_path option for when the heuristics fail.

google/pprof#366

@ardan-bkennedy
Copy link

Brilliant and Thank You!

@marwan-at-work
Copy link
Contributor

marwan-at-work commented Jun 12, 2018

im currently on the same machine, not on a different one. And I can't run -web. This is what I get when I run pprof -web cpu.prof

FATAL[0000] couldn't read file: /Users/xxx/go/src/github.com/marwan-at-work/xxx/var/folders/n4/35bgdnkd6vlgqrdzbyl0x1ycmhcndx/T/pprof002.svg error=open /Users/xxx/go/src/github.com/marwan-at-work/xxx/var/folders/n4/35bgdnkd6vlgqrdzbyl0x1ycmhcndx/T/pprof002.svg: no such file or directory
pprof: exit status 1

Same thing when I do -weblist <arg> from inside the pprof cli.

@phemmer
Copy link
Author

phemmer commented Jun 12, 2018

@marwan-at-work Please open a different issue. That's not what this one is about.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

7 participants