Skip to content

Place POSIX shadow files in /tmp on QNX, not the cwd - #112

Merged
dallison merged 1 commit into
mainfrom
fix-qnx-shadow-file-tmp-path
Jul 9, 2026
Merged

Place POSIX shadow files in /tmp on QNX, not the cwd#112
dallison merged 1 commit into
mainfrom
fix-qnx-shadow-file-tmp-path

Conversation

@dallison

@dallison dallison commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

On QNX, subspace_<sessionid>_<channel>_<index> files were being created in the current working directory of whatever process created a buffer, rather than in /tmp.

These are the POSIX-mode shadow files: in SUBSPACE_SHMEM_MODE_POSIX (macOS and QNX) the shared memory object is named/sized via a small on-disk file (its length records the buffer's true size, since fstat on the shm object is page-aligned, and its inode names the shm object — see PosixSharedMemoryName).

The bug was in Channel::BufferSharedMemoryName: it only special-cased __APPLE__ for the /tmp/ prefix. QNX (also POSIX mode) fell through to the generic branch and returned a bare relative name, so:

  • The shadow file landed in the process's cwd instead of /tmp.
  • The server's cleanup, keyed off /tmp, missed these files and leaked the underlying shm object whenever the server and publishers ran from different working directories.

Fix

Key the /tmp/ shadow-file path on SUBSPACE_SHMEM_MODE == SUBSPACE_SHMEM_MODE_POSIX so it applies to both macOS and QNX. The Linux /dev/shm path is an shm_open object name (not a filesystem path) and is left untouched.

Test plan

  • bazelisk test //... --config=macos_arm64 (POSIX mode) — all pass; macOS shadow-file path unchanged (still /tmp).
  • Verify on QNX that shadow files now appear under /tmp and are cleaned up on channel/session teardown.

Channel::BufferSharedMemoryName only special-cased __APPLE__ for the
/tmp shadow file path; other POSIX-mode platforms (notably QNX) fell
through to the generic branch and returned a bare relative name.  That
created subspace_<session>_<channel>_<index> shadow files in the
process's current working directory instead of /tmp, and made the
server's cleanup miss them (leaking the underlying shm object) whenever
the server and publishers ran from different directories.

Key the /tmp path on SUBSPACE_SHMEM_MODE_POSIX so both macOS and QNX
use it, and leave the Linux /dev/shm object-name path untouched.
@dallison
dallison merged commit 171a00c into main Jul 9, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant