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

Open
plugwash opened this issue Jul 7, 2024 · 3 comments
Open

Tests fail with latest rustc. #250

plugwash opened this issue Jul 7, 2024 · 3 comments

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.

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

2 participants