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: package emits invalid memory profile #6906

Closed
gopherbot opened this issue Dec 6, 2013 · 10 comments
Closed

runtime/pprof: package emits invalid memory profile #6906

gopherbot opened this issue Dec 6, 2013 · 10 comments

Comments

@gopherbot
Copy link
Contributor

by majek04:

What steps will reproduce the problem?

    $ cat << EOF > simple.mprof
heap profile: 10141899: 3497395080 [61368113: 46518687552] @ heap/1048576
6: 0 [12: 192] @ 0x42d56f 0x42e8c8 0x417e07 0x417fdd 0x601887 0x602f11 0x5140dc 0x51431c
0x51431c 0x514596 0x514ef5 0x510ccf 0x50b523 0x4c32ed 0x4ca90d 0x425b20
53: 0 [159: 2544] @ 0x42d56f 0x42e9d1 0x42ea5a 0x42a4ad 0x42a3e8 0x4e27cf 0x4e26bb
0x511722 0x512d4f 0x514d4d 0x5138bf 0x512b75 0x514d4d 0x510ccf 0x50b523 0x4c32ed
0x4ca90d 0x425b20
    EOF
    $ go tool pprof /bin/sh simple.mprof 

(simple.mprof also available here  [1])

What is the expected output?

    Although I simplified the mprof file, the two extracted lines are from real profile. Either the memory profiler is broken to generate this lines or the pprof is broken not to accept it. Or most likely both.

    The problem is with the second field. Pprof assumes that if first field is not zero, second must not be zero. This is not the case in mprofs generated in real world.

What do you see instead?

    pprof crashes. It should not.

Which version are you using?  (run 'go version')

    $ hg id
    87dea3f5ebe7+ (release-branch.go1.2) go1.2/release


Please provide any additional information below.

    Here's a quick-and-dirty patch [2]. Not sure if it's correct as I can't find any documentation of mprof file format.

[1] 
https://gist.github.com/majek/fe71148abac09b7f867a/raw/34f4d1978b816e02557d2d3b26038da123ef34c9/simple.mprof

[2]
https://gist.github.com/majek/fe71148abac09b7f867a/raw/28fc6638e8e699ac0e87300eed3bfb4254384c2f/pprof.patch
@DanielMorsing
Copy link
Contributor

Comment 1:

The profile is saying that a non-zero number of objects are occupying zero bytes. I'm
pretty sure this is a bug in the runtime since we don't profile zero sized allocations.

Labels changed: added repo-main, release-go1.3maybe.

Status changed to Accepted.

@dvyukov
Copy link
Member

dvyukov commented Feb 11, 2014

Comment 2:

How to reproduce this bad profile?
Can you please symbolize it or create an svg from it?

@DanielMorsing
Copy link
Contributor

Comment 3:

The pprof tool just fails to start and I can't make an svg or symbolize the profile
without removing the offending entry.

@dvyukov
Copy link
Member

dvyukov commented Feb 11, 2014

Comment 4:

But it must work with the fix [2]. Or plain addr2line must work.

@DanielMorsing
Copy link
Contributor

Comment 5:

Did some text surgery on the memprof file. The offending entry is created at
src/pkg/crypto/x509/pkix/pkix.go:80

@dvyukov
Copy link
Member

dvyukov commented Feb 11, 2014

Comment 6:

what version of Go? OS? is it possible to reproduce it?

@DanielMorsing
Copy link
Contributor

Comment 7:

Using Go 1.2, running on Linux. It happens about once a week, but I've yet to find a
reproducer.
I'll insert some checks into our runtime so that I have more info once this happens next.

@dvyukov
Copy link
Member

dvyukov commented Feb 12, 2014

Comment 8:

I've tried to run std tests with the following patch and -memprofilerate=1024:
https://golang.org/cl/62130043/diff/20001/src/pkg/runtime/mprof.goc
but it did not catch anything.
Maybe it will help you to localize the problem...

@rsc
Copy link
Contributor

rsc commented Apr 3, 2014

Comment 9:

Labels changed: added release-none, removed release-go1.3maybe.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@prattmic
Copy link
Member

prattmic commented Oct 3, 2023

The Go version of pprof handles this profile OK:

$ pprof -sample_index=0 -top /tmp/mprof
Main binary filename not available.
Type: alloc_objects
Showing nodes accounting for 5603413, 100% of 5603413 total
      flat  flat%   sum%        cum   cum%
   5603413   100%   100%    5603413   100%  <unknown>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants