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

Can not output flamegraph #253

Open
tc19901016 opened this issue Oct 13, 2024 · 0 comments
Open

Can not output flamegraph #253

tc19901016 opened this issue Oct 13, 2024 · 0 comments

Comments

@tc19901016
Copy link

I write a simple code and want to output the flamegraph. But the programe show some error. I found some issue has the same error, but we have no idea to fix this error. My rust version is rustc 1.79.0 (129f3b996 2024-06-10), my OS is CentOS7
the error is :

   Compiling greeting v0.1.0 (/root/rust/greeting)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.65s
     Running `/root/rust/greeting/target/debug/greeting`
Hello, world!:49995000
thread 'main' panicked at library/core/src/panicking.rs:220: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`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

my code is below:

fn main() {
    let guard=pprof::ProfilerGuard::new(100).unwrap();
    let mut sum=0;
    for i in 0..10000{
        sum+=i;
    }
    println!("Hello, world!:{}", sum);

    if let Ok(report) = guard.report().build(){
        println!("report:{:?}", report);
        let file = std::fs::File::create("~/flamegraph.svg").unwrap();
        report.flamegraph(file).unwrap();
    }else{
        println!("error report");
    }
}

the Cargo.toml is below:

[package]
name = "greeting"
version = "0.1.0"
edition = "2021"

[dependencies]
pprof ={version="0.13", features=["flamegraph"]}

the package is very simple, I think you can replicate the error.
thank you.

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

No branches or pull requests

1 participant