From 70311be21766850356e776baf38b2f5d38851fa7 Mon Sep 17 00:00:00 2001 From: Simon Chopin Date: Mon, 26 Oct 2026 12:09:52 +0100 Subject: [PATCH] mach: read_string: don't read unreadable memory On my system, when trying to read the process exec path from the stack, it would systematically fail because it would include a guard page that sits right after the stack. --- src/mac/streams/module_list.rs | 8 -------- src/mac/task_dumper.rs | 8 +++++++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mac/streams/module_list.rs b/src/mac/streams/module_list.rs index dfc8fe6e..4cb958da 100644 --- a/src/mac/streams/module_list.rs +++ b/src/mac/streams/module_list.rs @@ -344,14 +344,6 @@ mod test { /// both the local and intra-process scenarios #[test] fn images_match() { - if std::env::var_os("CI").is_some() && cfg!(target_arch = "aarch64") { - // https://github.com/rust-minidump/minidump-writer/issues/101 - println!( - "this fails on github actions but works on a local aarch64-apple-darwin machine..." - ); - return; - } - let mdw = MinidumpWriter::new(None, None); let td = TaskDumper::new(mdw.task); diff --git a/src/mac/task_dumper.rs b/src/mac/task_dumper.rs index e479ee45..0798801a 100644 --- a/src/mac/task_dumper.rs +++ b/src/mac/task_dumper.rs @@ -104,6 +104,12 @@ pub struct VMRegionInfo { pub range: std::ops::Range, } +impl VMRegionInfo { + fn is_readable(&self) -> bool { + self.info.protection & mach2::vm_prot::VM_PROT_READ != 0 + } +} + /// Similarly to PtraceDumper for Linux, this provides access to information /// for a task (MacOS process) pub struct TaskDumper { @@ -205,7 +211,7 @@ impl TaskDumper { if size_to_end < 4 * 1024 { let maybe_adjacent = self.get_vm_region(region.range.end)?; - if maybe_adjacent.range.start == region.range.end { + if maybe_adjacent.range.start == region.range.end && maybe_adjacent.is_readable() { size_to_end += maybe_adjacent.range.end - maybe_adjacent.range.start; } }