Skip to content

Commit f5eccae

Browse files
committed
fix bug in CopyPipe in mac os
1 parent 418fbc8 commit f5eccae

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

libdd-library-config/src/otel_process_ctx/reader/copy_pipe_unix.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ impl ProcessMemoryCopy for CopyPipe {
7777
io::ErrorKind::WouldBlock,
7878
"process context memory was unmapped during read",
7979
),
80-
pipe_dirty: false,
80+
// actually false on Linux: if EFAULT is returned, nothing was written;
81+
// should anything have been written already we would get a short write
82+
// However, this is not the case for macOS, despite what its manual
83+
// says: See https://github.com/apple-oss-distributions/xnu/blob/5c306bec31e314fa4d8bbdafb2f6f5a6b7e7b291/bsd/man/man2/write.2#L168-L186
84+
pipe_dirty: true,
8185
});
8286
}
8387
_ => {
@@ -291,7 +295,7 @@ mod tests {
291295
.expect_err("a copy crossing into inaccessible memory should fail");
292296

293297
assert_eq!(err.err.kind(), io::ErrorKind::WouldBlock);
294-
assert!(!err.pipe_dirty);
298+
assert!(err.pipe_dirty);
295299
// SAFETY: address and len came from mmap above.
296300
assert_eq!(unsafe { libc::munmap(address, len) }, 0);
297301
}

0 commit comments

Comments
 (0)