tikv / pprof-rs

A Rust CPU profiler implemented with the help of backtrace-rs
Apache License 2.0
1.26k stars 94 forks source link

fix: use T aligned pointer in TempFdArray #241

Open Erigara opened 5 months ago

Erigara commented 5 months ago

Fix for problem highlighted by #232.

I've observed app crash on my MacOS m1 machine with frame-pointer feature enabled due to unaligned pointer in slice_from_raw_parts.

Direct call to alloc is used to create properly aligned pointer.

ManuallyDrop<T> was used instead of T when creating TempFdArrayIterator to prevent use after drop since try_iter might be called more than once (not sure that strictly required since afaik UnresolvedFrames shouldn't allocate any memory).

Erigara commented 5 months ago

Formatting and clippy should be fine now :)

Erigara commented 4 months ago

@YangKeao hello, do you have any estimates on reviewing this PR?

Venryx commented 1 month ago

We also experience issue #232 on rust nightly-2024-03-05, with pprof as a subdependency of pyroscope_pprofrs. (we get the error in #232 at program startup)

I've tried applying the modifications in this PR, and it appears to fully resolve the startup error in our project. (letting us now use pyroscope_pprofrs)

Is there a blocker on merging of this PR? Or other ways we can help get it validated/merged?