diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index aaadff55..15ba479d 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: deny audit uses: EmbarkStudios/cargo-deny-action@v1 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b007bd23..3fd572cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,8 @@ jobs: strategy: matrix: job: - - { os: ubuntu-20.04 , target: x86_64-unknown-linux-gnu } - - { os: ubuntu-20.04, target: x86_64-unknown-linux-musl } + - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu } + - { os: ubuntu-22.04, target: x86_64-unknown-linux-musl } - { os: windows-2022, target: x86_64-pc-windows-msvc } - { os: macos-12, target: x86_64-apple-darwin } # TODO: Add macos aarch64 here once it becomes available as a runner @@ -57,17 +57,17 @@ jobs: strategy: matrix: job: - - { os: ubuntu-latest, target: i686-unknown-linux-gnu, use-cross: true } + - { os: ubuntu-22.04, target: i686-unknown-linux-gnu, use-cross: true } #- { os: ubuntu-latest, target: i686-unknown-linux-musl, use-cross: true } - - { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, use-cross: true } - - { os: ubuntu-latest, target: aarch64-unknown-linux-musl, use-cross: true } - - { os: ubuntu-latest, target: aarch64-linux-android, use-cross: true } - - { os: ubuntu-latest, target: arm-unknown-linux-gnueabi, use-cross: true } - - { os: ubuntu-latest, target: arm-unknown-linux-musleabi, use-cross: true } - - { os: ubuntu-latest, target: arm-linux-androideabi, use-cross: true } - - { os: ubuntu-latest, target: arm-unknown-linux-gnueabihf, use-cross: true } + - { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu, use-cross: true } + - { os: ubuntu-22.04, target: aarch64-unknown-linux-musl, use-cross: true } + #- { os: ubuntu-22.04, target: aarch64-linux-android, use-cross: true } + - { os: ubuntu-22.04, target: arm-unknown-linux-gnueabi, use-cross: true } + - { os: ubuntu-22.04, target: arm-unknown-linux-musleabi, use-cross: true } + - { os: ubuntu-22.04, target: arm-linux-androideabi, use-cross: true } + - { os: ubuntu-22.04, target: arm-unknown-linux-gnueabihf, use-cross: true } # TODO: Remove this when aarch64 macs can be used as runners - - { os: macos-latest, target: aarch64-apple-darwin, use-cross: false } + - { os: macos-12, target: aarch64-apple-darwin, use-cross: false } steps: - uses: actions/checkout@v3 - name: Install Rust diff --git a/Cargo.toml b/Cargo.toml index 0d16cd7a..ee85b34f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" byteorder = "1.3.2" cfg-if = "1.0" crash-context = "0.5" -memoffset = "0.7" +memoffset = "0.8" minidump-common = "0.15" scroll = "0.11" tempfile = "3.1.0" @@ -24,7 +24,7 @@ goblin = "0.6" memmap2 = "0.5" [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] -nix = { version = "0.25", default-features = false, features = [ +nix = { version = "0.26", default-features = false, features = [ "mman", "process", "ptrace", diff --git a/src/bin/test.rs b/src/bin/test.rs index 08a98618..accbc998 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -207,11 +207,11 @@ mod linux { fn spawn_mmap_wait() -> Result<()> { let page_size = nix::unistd::sysconf(nix::unistd::SysconfVar::PAGE_SIZE).unwrap(); - let memory_size = page_size.unwrap() as usize; + let memory_size = std::num::NonZeroUsize::new(page_size.unwrap() as usize).unwrap(); // Get some memory to be mapped by the child-process let mapped_mem = unsafe { mmap( - std::ptr::null_mut(), + None, memory_size, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE, MapFlags::MAP_PRIVATE | MapFlags::MAP_ANON, diff --git a/src/linux/dso_debug.rs b/src/linux/dso_debug.rs index 7aa60adb..b77f2413 100644 --- a/src/linux/dso_debug.rs +++ b/src/linux/dso_debug.rs @@ -42,21 +42,21 @@ pub struct LinkMap { } // COPY from -#[derive(Debug, Clone)] +/// This state value describes the mapping change taking place when +/// the `r_brk' address is called. +#[derive(Debug, Clone, Default)] #[allow(non_camel_case_types, unused)] #[repr(C)] enum RState { - /* This state value describes the mapping change taking place when - the `r_brk' address is called. */ - RT_CONSISTENT, /* Mapping change is complete. */ - RT_ADD, /* Beginning to add a new object. */ - RT_DELETE, /* Beginning to remove an object mapping. */ -} -impl Default for RState { - fn default() -> Self { - RState::RT_CONSISTENT // RStates are not used anyway - } + /// Mapping change is complete. + #[default] + RT_CONSISTENT, + /// Beginning to add a new object. + RT_ADD, + /// Beginning to remove an object mapping. + RT_DELETE, } + // COPY from #[derive(Debug, Clone, Default)] #[repr(C)] diff --git a/src/linux/ptrace_dumper.rs b/src/linux/ptrace_dumper.rs index 30a4d368..2380afb0 100644 --- a/src/linux/ptrace_dumper.rs +++ b/src/linux/ptrace_dumper.rs @@ -213,7 +213,6 @@ impl PtraceDumper { if task_path.is_dir() { std::fs::read_dir(task_path) .map_err(|e| InitError::IOError(filename, e))? - .into_iter() .filter_map(|entry| entry.ok()) // Filter out bad entries .filter_map(|entry| { entry diff --git a/tests/ptrace_dumper.rs b/tests/ptrace_dumper.rs index a69631c5..02ba836a 100644 --- a/tests/ptrace_dumper.rs +++ b/tests/ptrace_dumper.rs @@ -114,8 +114,8 @@ fn test_linux_gate_mapping_id() { #[test] fn test_merged_mappings() { let page_size = nix::unistd::sysconf(nix::unistd::SysconfVar::PAGE_SIZE).unwrap(); - let page_size = page_size.unwrap() as usize; - let map_size = 3 * page_size; + let page_size = std::num::NonZeroUsize::new(page_size.unwrap() as usize).unwrap(); + let map_size = std::num::NonZeroUsize::new(3 * page_size.get()).unwrap(); let path: &'static str = std::env!("CARGO_BIN_EXE_test"); let file = std::fs::File::open(path).unwrap(); @@ -124,7 +124,7 @@ fn test_merged_mappings() { // enclosed in the other, but with different protections. let mapped_mem = unsafe { mmap( - std::ptr::null_mut(), + None, map_size, ProtFlags::PROT_READ, MapFlags::MAP_SHARED, @@ -137,14 +137,14 @@ fn test_merged_mappings() { // Carve a page out of the first mapping with different permissions. let _inside_mapping = unsafe { mmap( - (mapped_mem as usize + 2 * page_size) as *mut libc::c_void, + std::num::NonZeroUsize::new(mapped_mem as usize + 2 * page_size.get()), page_size, ProtFlags::PROT_NONE, MapFlags::MAP_SHARED | MapFlags::MAP_FIXED, file.as_raw_fd(), // Map a different offset just to // better test real-world conditions. - page_size.try_into().unwrap(), // try_into() in order to work for 32 and 64 bit + page_size.get().try_into().unwrap(), // try_into() in order to work for 32 and 64 bit ) }; @@ -153,7 +153,7 @@ fn test_merged_mappings() { &[ path, &format!("{}", mapped_mem as usize), - &format!("{}", map_size), + &format!("{map_size}"), ], ); }