Skip to content

Commit 9506028

Browse files
wan9chicodex
andcommitted
docs(fspy): scope macOS resize safety
Co-authored-by: GPT-5 Codex <codex@openai.com>
1 parent 9c3ad95 commit 9506028

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • crates/fspy_shm/src/macos

crates/fspy_shm/src/macos/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ pub fn create(size: usize) -> io::Result<Shm> {
7474
pub fn open(id: &str) -> io::Result<Shm> {
7575
// `rustix::shm::open` sets `FD_CLOEXEC` on the returned descriptor.
7676
let fd = shm::open(id, OFlags::RDWR, Mode::empty()).map_err(io::Error::from)?;
77-
// Another process that opens this object for writing can resize it. If it
78-
// shrinks the object after `fstat`, `mmap` rejects the requested size and
79-
// `open` returns an error. Fspy sets the size before sharing `id` and never
80-
// changes it afterward.
77+
// If another process shrinks the object before `mmap`, `mmap` returns an
78+
// error. If it resizes the object after `mmap`, `open` does not access the
79+
// mapped pages. A concurrent resize cannot make `open` access invalid memory.
8180
let stat = fstat(&fd)?;
8281
let size = usize::try_from(stat.st_size)
8382
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "invalid shared-memory size"))?;

0 commit comments

Comments
 (0)