Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion common/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,14 @@ Channel::PosixSharedMemoryName(const std::string &shadow_file) {
// Use the inode number (unique per file) to make the shm file name.
// st_ino is unsigned and can be 64-bit on some systems (e.g. QNX), so
// promote to uint64_t before formatting.
return absl::StrFormat("subspace_%llu",
//
// The leading '/' is required: POSIX shm_open names that do not start with
// '/' are implementation-defined. On QNX they resolve relative to the
// process cwd, so a publisher started under
// /applications/install/opt/<App>/ creates objects that a subscriber
// started from '/' cannot open (ENOENT). A leading slash places the object
// in the global shm namespace (macOS also requires a leading '/').
return absl::StrFormat("/subspace_%llu",
static_cast<unsigned long long>(st.st_ino));
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion rust_client/src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,9 @@ fn create_shm(name: &str, size: usize) -> crate::error::Result<RawFd> {
#[cfg(not(target_os = "linux"))]
fn posix_shm_name(shadow_path: &str) -> crate::error::Result<String> {
let stat = crate::syscall_shim::shim_stat(shadow_path)?;
Ok(format!("subspace_{}", stat.st_ino))
// POSIX shm names must use the global namespace so Rust and C++ clients
// resolve the same object even when their working directories differ.
Ok(format!("/subspace_{}", stat.st_ino))
}

#[cfg(not(target_os = "linux"))]
Expand Down
Loading