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

Tests fail with latest rustc. #250

Closed
plugwash opened this issue Jul 7, 2024 · 5 comments · Fixed by #255
Closed

Tests fail with latest rustc. #250

plugwash opened this issue Jul 7, 2024 · 5 comments · Fixed by #255

Comments

@plugwash
Copy link

plugwash commented Jul 7, 2024

Related to #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

@shinmao
Copy link

shinmao commented Aug 17, 2024

@plugwash , do you have any other case that could trigger the panic on validate? As far as I know, even though the test suite panic; however, no one will use it like this way (pass a constant address), isn't it?

assert!(!validate(-1_i32 as usize as *const libc::c_void))

@plugwash
Copy link
Author

No, I simply ran into the test failure while working on Debian rust packaging.

@shinmao
Copy link

shinmao commented Aug 19, 2024

Yes. I think validate(-1_i32 as usize as *const libc::c_void) is expected to return false here; however, it panic due to precondition check in from_raw_parts.

@vorporeal
Copy link

Just dug into this a little and found that adding an if addr.is_null() { return false; } check at the top of the validate() function fixes the problem for me.

Wish the maintainers of this repo were responsive; seems like it might be an easy fix. :(

@mati865
Copy link

mati865 commented Nov 7, 2024

Just switch to pprof2 maintained by Embark Studios.

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

Successfully merging a pull request may close this issue.

4 participants