Skip to content

Fix QSharedMemory on macOS with Qt 6.6+#215

Merged
itay-grudev merged 2 commits into
itay-grudev:masterfrom
Omkar-Darekar:fix/macos-qt6-shared-memory
Jun 16, 2026
Merged

Fix QSharedMemory on macOS with Qt 6.6+#215
itay-grudev merged 2 commits into
itay-grudev:masterfrom
Omkar-Darekar:fix/macos-qt6-shared-memory

Conversation

@Omkar-Darekar

Copy link
Copy Markdown
Contributor

Qt 6.6+ defaults to POSIX Realtime shared memory via QNativeIpcKey on macOS. However, POSIX shared memory (shm_open) requires Qt to be built with -feature-ipc_posix and has strict naming requirements.

Many Qt installations (including Homebrew) don't have POSIX IPC enabled, causing the error:
QSharedMemory::KeyError "QSharedMemory::attach (shm_open): bad name"

Use legacyNativeKey() to force System V shared memory, which works reliably on all macOS configurations regardless of Qt build options.

Fixes single instance detection failing on macOS with Qt 6.6+.

Omkar Darekar and others added 2 commits May 15, 2026 15:31
Qt 6.6+ defaults to POSIX Realtime shared memory via QNativeIpcKey on
macOS. However, POSIX shared memory (shm_open) requires Qt to be built
with -feature-ipc_posix and has strict naming requirements.

Many Qt installations (including Homebrew) don't have POSIX IPC enabled,
causing the error:
  QSharedMemory::KeyError "QSharedMemory::attach (shm_open): bad name"

Use legacyNativeKey() to force System V shared memory, which works
reliably on all macOS configurations regardless of Qt build options.

Fixes single instance detection failing on macOS with Qt 6.6+.
@itay-grudev itay-grudev merged commit ccc013e into itay-grudev:master Jun 16, 2026
10 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.

2 participants