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

pprof panic on recent toolchains #174

Closed
korniltsev opened this issue Jul 26, 2024 · 3 comments · Fixed by #183
Closed

pprof panic on recent toolchains #174

korniltsev opened this issue Jul 26, 2024 · 3 comments · Fixed by #183
Labels
bug Something isn't working

Comments

@korniltsev
Copy link
Collaborator

This simple program panics on recent toolchains

use pyroscope::PyroscopeAgent;
use pyroscope_pprofrs::{pprof_backend, PprofConfig};

fn main() {
    let pprof_config = PprofConfig::new().sample_rate(100);
    let pprof_backend = pprof_backend(pprof_config);

    let pprof_agent =
        PyroscopeAgent::builder("https://asd.net", "qwe")
            .basic_auth("xxx", "xxxx")
            .backend(pprof_backend)
            .build().unwrap();

    let running_agent = pprof_agent.start().unwrap();

    let (add_tag, _) = running_agent.tag_wrapper();

    let _ = add_tag("connections".to_string(), 10.to_string());
    let _ = add_tag("watchers".to_string(), 10.to_string());

    running_agent.stop().unwrap().shutdown();
}

panic:

/home/korniltsev/.cargo/bin/cargo run --color=always --package pg --bin pg
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/pg`
thread 'main' panicked at library/core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
stack backtrace:
   0: rust_begin_unwind
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/std/src/panicking.rs:661:5
   1: core::panicking::panic_nounwind_fmt::runtime
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/panicking.rs:112:18
   2: core::panicking::panic_nounwind_fmt
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/panicking.rs:122:5
   3: core::panicking::panic_nounwind
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/panicking.rs:221:5
   4: core::slice::raw::from_raw_parts::precondition_check
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/ub_checks.rs:68:21
   5: core::slice::raw::from_raw_parts
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/ub_checks.rs:75:17
   6: <pprof::collector::TempFdArrayIterator<T> as core::iter::traits::iterator::Iterator>::next
             at /home/korniltsev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/collector.rs:225:26
   7: core::iter::traits::iterator::Iterator::fold
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/iter/traits/iterator.rs:2587:29
   8: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/iter/adapters/chain.rs:126:19
   9: core::iter::traits::iterator::Iterator::for_each
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/iter/traits/iterator.rs:818:9
  10: pprof::report::ReportBuilder::build
             at /home/korniltsev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/report.rs:110:17
  11: pyroscope_pprofrs::Pprof::dump_report
             at /home/korniltsev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyroscope_pprofrs-0.2.7/src/lib.rs:202:22
  12: <pyroscope_pprofrs::Pprof as pyroscope::backend::backend::Backend>::add_rule
             at /home/korniltsev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyroscope_pprofrs-0.2.7/src/lib.rs:180:13
  13: pyroscope::pyroscope::PyroscopeAgent<pyroscope::pyroscope::PyroscopeAgentRunning>::tag_wrapper::{{closure}}
             at /home/korniltsev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyroscope-0.5.7/src/pyroscope.rs:776:17
  14: pg::main
             at ./src/main.rs:18:13
  15: core::ops::function::FnOnce::call_once
             at /rustc/6292b2af620dbd771ebb687c3a93c69ba8f97268/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread caused non-unwinding panic. aborting.

Process finished with exit code 134 (interrupted by signal 6:SIGABRT)









@korniltsev korniltsev added the bug Something isn't working label Jul 26, 2024
@Yerkwell
Copy link

Yerkwell commented Aug 6, 2024

Looks like it's problem in pprof-rs crate, which won't be fixed any soon as it looks abandoned (last update was almost a year ago). As I understood from googling, the problem has always been there, but started panicking only recently (at rust 1.78.0). So, downgrading may be a workaround, maybe?

@korniltsev
Copy link
Collaborator Author

tikv/pprof-rs#232

@DeanHnter
Copy link

I receive the same error on M1 with pyroscope for Rust on Macos M1

thread '' panicked at library/core/src/panicking.rs:219:5: unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceedisize::MAXstack backtrace: 0: rust_begin_unwind at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5 1: core::panicking::panic_nounwind_fmt::runtime at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:110:18 2: core::panicking::panic_nounwind_fmt at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:120:5 3: core::panicking::panic_nounwind at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:219:5 4: core::slice::raw::from_raw_parts::precondition_check at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ub_checks.rs:68:21 5: core::slice::raw::from_raw_parts at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ub_checks.rs:75:17 6: pprof::addr_validate::validate at /Users/deanhunter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/addr_validate.rs:93:28 7: <pprof::backtrace::frame_pointer::Trace as pprof::backtrace::Trace>::trace at /Users/deanhunter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/backtrace/frame_pointer.rs:114:17 8: perf_signal_handler at /Users/deanhunter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pprof-0.12.1/src/profiler.rs:354:13 9: ___simple_bprintf note: Some details are omitted, run withRUST_BACKTRACE=fullfor a verbose backtrace. thread caused non-unwinding panic. aborting.

mati865 added a commit to mati865/pyroscope-rs that referenced this issue Nov 5, 2024
The original `pprof` crate is long abandoned and doesn't work with recent toolchains.
There is a new `pprof2` crate that contains fixes and works with recent toolchains.

Fixes grafana#174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants