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

Tests fail with latest rustc. #250

Open plugwash opened 1 week ago

plugwash commented 1 week ago

Related to https://github.com/tikv/pprof-rs/issues/232

The "validate" function tries to write data to a pipe from a pointer of unknown validity.

Unfortunately, the function tries to convert the possibly-invalid pointer to a slice, this is unsound and with recent rustc leads to the testsuite panicing

thread 'addr_validate::test::failed_validate' 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`

In Debian I fixed this by using libc::write directly instead of nix::unistd::write

https://salsa.debian.org/rust-team/debcargo-conf/-/blob/master/src/pprof/debian/patches/use-libc-write-for-validation.patch