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: provide memory mapping info on macOS #19790

Open
hyangah opened this issue Mar 30, 2017 · 2 comments
Open

runtime/pprof: provide memory mapping info on macOS #19790

hyangah opened this issue Mar 30, 2017 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Mar 30, 2017

Noticed during google/pprof#120

https://github.com/golang/go/blob/master/src/runtime/pprof/proto.go#L370
depends on /proc/self/maps which results in missing memory mapping info in
profile data from non-linux system (e.g. OSX).

Provide it to help offline symbolization for non-Go symbols.

@rsc rsc changed the title runtime/pprof: provide memory mapping info on OSX runtime/pprof: provide memory mapping info on macOS Mar 30, 2017
@rsc
Copy link
Contributor

rsc commented Mar 30, 2017

Note that all the non-Linux systems have this problem, and that the problem only affects fetching symbol information for dynamic libraries the binary is linked against, not the main binary.

For macOS in particular, from searching around it seems that /usr/bin/vmmap is the suggested way to get that information, and it is in turn implemented using mach_vm_region_recurse. However, vmmap asks to be root to run. I don't know of mach_vm_region_recurse on our own process will require root privileges or not. If it does, that's a non-starter.

@andybons andybons added NeedsFix The path to resolution is known, but the work has not been done. help wanted labels Apr 11, 2018
@andybons andybons added this to the Unplanned milestone Apr 11, 2018
@gopherbot
Copy link

Change https://golang.org/cl/123779 mentions this issue: runtime/pprof: add a fake mapping when /proc/self/maps is unavailable

gopherbot pushed a commit that referenced this issue Jul 16, 2018
Profile's Mapping field is currently populated by reading /proc/self/maps.
On systems where /proc/self/maps is not available, the profile generated
by Go's runtime will not have any Mapping entry. Pprof command then adds
a fake entry and links all Location entries in the profile with the fake
entry to be used during symbolization.
https://github.com/google/pprof/blob/a8644067d5a3c9a6386e7c88fa4a3d9d37877ca3/internal/driver/fetch.go#L437

The fake entry is not enough to suppress the error or warning messages
pprof command produces. We need to tell pprof that Location entries are
symbolized already by Go runtime and pprof does not have to attempt to
perform further symbolization.

In #25743, we made Go runtime mark Mapping entries with HasFunctions=true
when all Location entries from the Mapping entries are successfully
symbolized. This change makes the Go runtime add a fake mapping entry,
otherwise the pprof command tool would add, and set the HasFunctions=true
following the same logic taken when the real mapping information is
available.

Updates #19790.
Fixes #26255. Tested pprof doesn't report the error message any more
for pure Go program.

Change-Id: Ib12b62e15073f5d6c80967e44b3e8709277c11bd
Reviewed-on: https://go-review.googlesource.com/123779
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@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. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants