flamegraph-rs / flamegraph

Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flamegraph --palette=hot fails to downcast to Palette

jedbrown opened this issue · comments

I get this on current main (00d66a7). I don't know if this is a side-effect from an inferno or clap update.

$ RUST_BACKTRACE=1 cargo run --bin=flamegraph -- --palette hot -- true
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/flamegraph --palette hot -- true`
thread 'main' panicked at 'Mismatch between definition and access of `palette`. Could not downcast to inferno::flamegraph::color::Palette, need to downcast to alloc::string::String
', src/lib.rs:526:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/panicking.rs:67:14
   2: clap_builder::parser::error::MatchesError::unwrap
             at /home/jed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.2.7/src/parser/error.rs:32:9
   3: clap_builder::parser::matches::arg_matches::ArgMatches::remove_one
             at /home/jed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.2.7/src/parser/matches/arg_matches.rs:409:9
   4: <flamegraph::FlamegraphOptions as clap_builder::derive::FromArgMatches>::from_arg_matches_mut
             at ./src/lib.rs:492:17
   5: <flamegraph::Options as clap_builder::derive::FromArgMatches>::from_arg_matches_mut
             at ./src/lib.rs:462:12
   6: <flamegraph::Opt as clap_builder::derive::FromArgMatches>::from_arg_matches_mut
             at ./src/bin/flamegraph.rs:20:12
   7: clap_builder::derive::Parser::parse
             at /home/jed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.2.7/src/derive.rs:28:19
   8: flamegraph::main
             at ./src/bin/flamegraph.rs:31:15
   9: core::ops::function::FnOnce::call_once
             at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I suspect something in clap. Can you investigate more?

I ran into this today too, and traced it to a clap change. Clap moved from possible_values to value_parser for defining the set of valid values for an option, but with value_parser it seems that Palette bring FromStr isn't enough to cast it correctly. More here: clap-rs/clap#3855

Anyone wants to submit a PR to solve this?

Thanks for the link @mwcz. I made a PR.