flamegraph icon indicating copy to clipboard operation
flamegraph copied to clipboard

unable to generate a flamegraph from the collapsed stack data

Open zeeshanlakhani opened this issue 5 years ago • 15 comments

I'm receiving this error error within an ubuntu container running on a VM (Virtualbox) atop MacOS Mojave (via multiple runs on 0.1.13 and the current git/master version):

cargo flamegraph --bin=skeleton -- --file=skeleton.toml

Then everything runs as expected, but then:

...
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.119 MB perf.data (8 samples) ]
writing flamegraph to "flamegraph.svg"
thread 'main' panicked at 'unable to generate a flamegraph from the collapsed stack data: Io(Custom { kind: InvalidData, error: "No stack counts found" })', src/libcore/result.rs:1165:5

Seemingly related to https://github.com/ferrous-systems/flamegraph/issues/16, but this is now within a container on a VM instead.

Thanks.

zeeshanlakhani avatar Dec 11 '19 17:12 zeeshanlakhani

I wonder if using the new -c flag for manually specifying perf arguments could help you here, assuming perf works at all on the VM?

Maybe try different callgraph modes: fp (most likely to work), dwarf (default), and lbr (least likely to work) substituted for the below argument to --call-graph

cargo flamegraph -c "record -e instructions -c 100 --call-graph lbr -g"

spacejam avatar May 28 '20 06:05 spacejam

@spacejam I'm getting this same issue in Docker. Tried your suggested -c flag, but I got:

Error:
The instructions event is not supported.
failed to sample program

Removing that and trying fp alas did not help. Thanks for the suggestion though!

cloutiertyler avatar Sep 04 '22 06:09 cloutiertyler

still happening. no fix for this yet?

writing flamegraph to "flamegraph.svg"
Error: unable to generate a flamegraph from the collapsed stack data

Caused by:
    0: I/O error: No stack counts found
    1: No stack counts found

duckfromdiscord avatar Feb 05 '23 19:02 duckfromdiscord

this is on windows

duckfromdiscord avatar Feb 05 '23 19:02 duckfromdiscord

@nico-abram any tips?

djc avatar Feb 05 '23 20:02 djc

I just ran a quick test on windows on the tip of flamegraph's main branch. Seems to work via blondie on a simple test binary.

@duckfromdiscord Are you running flamegraph as admin? Do you have dtrace installed? Are you on windows 10? If so, could you share which version? (I recall running into a specific version which was a bit buggy in https://github.com/flamegraph-rs/flamegraph/pull/202#issuecomment-1129575600 )

If you have dtrace installed, flamegraph is using that to generate callstacks. You could try running dtrace manually with something like this:

dtrace "-x" "ustackframes=100" "-n" 'profile-997 /pid == $target/ { @[ustack(100)] = count(); }' "-o" "cargo-flamegraph.stacks" "-c" "path/to/your/binary"

dtrace on windows has a bug tracker here: https://github.com/microsoft/DTrace-on-Windows/issues

If you're running as admin and don't have dtrace, it's trying to use a library I wrote last year, I don't have a good guess as to what's happening . A test project would be useful.

nico-abram avatar Feb 05 '23 23:02 nico-abram

@nico-abram to answer your questions:

  • yeah, if I run not under admin i get could not find dtrace and could not profile using blondie: NotAnAdmin which is fine. the error I get is when running under an admin terminal
  • i do not think I have dtrace installed. will try to do that.
  • yes, I am on windows 10
  • i'm using a hello world project that comes with Rust for MRE

duckfromdiscord avatar Feb 05 '23 23:02 duckfromdiscord

Same here with dtrace windows

ahmtcn123 avatar Mar 18 '23 16:03 ahmtcn123

@ahmtcn123 see above, did you try with blondie?

djc avatar Mar 20 '23 16:03 djc

@djc Sorry for replying so late, Yes it works well with blondie.

ahmtcn123 avatar Mar 29 '23 21:03 ahmtcn123

I am running into the same (?) issue as the original poster, in my case on bare-metal macOS 13.4 (M1).

$ cargo flamegraph --root
dtrace: system integrity protection is on, some features will not be available

dtrace: description 'profile-997 ' matched 1 probe
Hello, world! # <<< test output of my binary
dtrace: pid 59523 has exited
writing flamegraph to "flamegraph.svg"
Error: unable to generate a flamegraph from the collapsed stack data

Caused by:
    0: I/O error: No stack counts found
    1: No stack counts found

The flamegraph is successfully generated sometimes, but in only like 2 out of 10 attempts.

miguno avatar Jun 09 '23 21:06 miguno

On macOS, maybe try https://github.com/mstange/samply instead of flamegraph. IME the dtrace backend has never worked very well.

djc avatar Jun 12 '23 08:06 djc

Thanks for this tip, @djc. Samply seems to work better on macOS.

miguno avatar Jun 12 '23 12:06 miguno