From fc794e92fdc87bdd93b6a2c9137afde73d300275 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 30 Apr 2025 16:43:51 -0700 Subject: [PATCH 1/3] Fix the assertion in `Pid::from_raw` to accept 0. (#1456) * Fix the assertion in `Pid::from_raw` to accept 0. Fix a regression from #1443 which disallowed calling `Pid::from_raw` with the value 0. * Disable transmutes warnings for now. * Add a test. * Update CI to ubuntu-22.04, as ubuntu-20.04 is no longer supported. * Fix the build on Rust 1.63. * Temporarily work around nightly build errors on powerpc64-ibm-aix. --- .github/workflows/main.yml | 9 +++++---- src/lib.rs | 6 ++++++ src/pid.rs | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f553a007b..14230a6b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -229,7 +229,8 @@ jobs: - run: cargo check -Z build-std --target=x86_64-pc-nto-qnx710 --features=all-apis - run: cargo check -Z build-std --target=armv6k-nintendo-3ds --all-features - run: cargo check -Z build-std --target=armv7-sony-vita-newlibeabihf --features=all-apis - - run: cargo check -Z build-std --target=powerpc64-ibm-aix --features=all-apis + # Temporarily disable due to build errors on nightly. + # - run: cargo check -Z build-std --target=powerpc64-ibm-aix --features=all-apis - run: cargo check -Z build-std --target=mipsel-unknown-linux-gnu --features=all-apis - run: cargo check -Z build-std --target=mips64el-unknown-linux-gnuabi64 --features=all-apis - run: cargo check -Z build-std --target=powerpc-unknown-linux-musl --features=all-apis @@ -246,13 +247,13 @@ jobs: RUSTFLAGS: --cfg rustix_use_experimental_features strategy: matrix: - build: [ubuntu, ubuntu-20.04, i686-linux, aarch64-linux, powerpc-linux, powerpc64le-linux, riscv64-linux, s390x-linux, arm-linux, ubuntu-stable, i686-linux-stable, aarch64-linux-stable, riscv64-linux-stable, s390x-linux-stable, powerpc-linux-stable, powerpc64le-linux-stable, arm-linux-stable, ubuntu-1.63, i686-linux-1.63, aarch64-linux-1.63, riscv64-linux-1.63, s390x-linux-1.63, powerpc64le-linux, powerpc64le-linux-1.63, arm-linux-1.63, macos-latest, macos-13, windows, windows-2019, musl] + build: [ubuntu, ubuntu-22.04, i686-linux, aarch64-linux, powerpc-linux, powerpc64le-linux, riscv64-linux, s390x-linux, arm-linux, ubuntu-stable, i686-linux-stable, aarch64-linux-stable, riscv64-linux-stable, s390x-linux-stable, powerpc-linux-stable, powerpc64le-linux-stable, arm-linux-stable, ubuntu-1.63, i686-linux-1.63, aarch64-linux-1.63, riscv64-linux-1.63, s390x-linux-1.63, powerpc64le-linux, powerpc64le-linux-1.63, arm-linux-1.63, macos-latest, macos-13, windows, windows-2019, musl] include: - build: ubuntu os: ubuntu-latest rust: nightly - - build: ubuntu-20.04 - os: ubuntu-20.04 + - build: ubuntu-22.04 + os: ubuntu-22.04 rust: nightly - build: i686-linux os: ubuntu-latest diff --git a/src/lib.rs b/src/lib.rs index 1621262ed..77f8a2158 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,6 +122,12 @@ #![allow(clippy::useless_conversion)] // This clippy lint gets too many false positives. #![allow(clippy::needless_lifetimes)] +// Until `unnecessary_transmutes` is recognized by our MSRV, don't warn about +// it being unrecognized. +#![allow(unknown_lints)] +// Until `cast_signed` and `cast_unsigned` are supported by our MSRV, don't +// warn about transmutes that could be changed to them. +#![allow(unnecessary_transmutes)] // Redox and WASI have enough differences that it isn't worth precisely // conditionalizing all the `use`s for them. Similar for if we don't have // "all-apis". diff --git a/src/pid.rs b/src/pid.rs index d09cba0e3..aa61892fe 100644 --- a/src/pid.rs +++ b/src/pid.rs @@ -41,7 +41,7 @@ impl Pid { /// [pidfd]: https://man7.org/linux/man-pages/man2/pidfd_open.2.html #[inline] pub const fn from_raw(raw: RawPid) -> Option { - debug_assert!(raw > 0); + debug_assert!(raw >= 0); match NonZeroI32::new(raw) { Some(non_zero) => Some(Self(non_zero)), None => None, @@ -115,4 +115,21 @@ mod tests { transmute::, RawPid>(Some(Pid::from_raw_unchecked(4567))) }); } + + #[test] + fn test_ctors() { + use std::num::NonZeroI32; + assert!(Pid::from_raw(0).is_none()); + assert_eq!( + Pid::from_raw(77).unwrap().as_raw_nonzero(), + NonZeroI32::new(77).unwrap() + ); + assert_eq!(Pid::as_raw(Pid::from_raw(77)), 77); + } + + #[test] + fn test_specials() { + assert!(Pid::from_raw(1).unwrap().is_init()); + assert_eq!(Pid::from_raw(1).unwrap(), Pid::INIT); + } } From 6883580f41f6055fced177f741a31b91a7e60fb4 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 30 Apr 2025 16:58:34 -0700 Subject: [PATCH 2/3] chore: Release rustix version 1.0.7 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c184e0808..87c66824d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustix" -version = "1.0.6" +version = "1.0.7" authors = [ "Dan Gohman ", "Jakub Konka ", From 06125d4cd41d0484d19f71a15d55e7d8cb2194e4 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 22 May 2025 09:39:15 -0700 Subject: [PATCH 3/3] Remove the `AT_BASE` platform checking from the auxv code. Rustix itself doesn't depend on the value of `AT_BASE`, so don't check and validate that it matches rustix's expectations. --- src/backend/linux_raw/param/auxv.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/backend/linux_raw/param/auxv.rs b/src/backend/linux_raw/param/auxv.rs index d748219a9..d7978f804 100644 --- a/src/backend/linux_raw/param/auxv.rs +++ b/src/backend/linux_raw/param/auxv.rs @@ -403,14 +403,6 @@ unsafe fn init_from_aux_iter(aux_iter: impl Iterator) -> Opti AT_EXECFN => execfn = check_raw_pointer::(a_val as *mut _)?.as_ptr(), AT_SYSINFO_EHDR => sysinfo_ehdr = check_elf_base(a_val as *mut _)?.as_ptr(), - AT_BASE => { - // The `AT_BASE` value can be null in a static executable that - // doesn't use a dynamic linker. If so, ignore it. - if !a_val.is_null() { - let _ = check_elf_base(a_val.cast())?; - } - } - #[cfg(feature = "runtime")] AT_SECURE => secure = (a_val as usize != 0) as u8 + 1, #[cfg(feature = "runtime")]