Skip to content

runtime/pprof: package emits invalid memory profile #6906

@gopherbot

Description

@gopherbot

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions