fix(native): replace sandbox-incompatible IPC primitives on macOS#1644
Merged
fix(native): replace sandbox-incompatible IPC primitives on macOS#1644
Conversation
macOS App Sandbox blocks sem_open(), shm_open(), and fork() in sandboxed apps, causing the native backend to fail during init. - Replace sem_open/sem_wait with pthread_mutex_t for IPC synchronization - Replace shm_open with file-backed mmap using $TMPDIR (sandbox-safe) - Replace fork+exec with posix_spawn using POSIX_SPAWN_CLOEXEC_DEFAULT and explicit fd inheritance via posix_spawn_file_actions_addinherit_np - Pass shm_fd to daemon via posix_spawn instead of reopening by name - Add macOS App Sandbox integration tests verifying init, crash capture, minidump generation, and native stacktraces inside a sandboxed .app Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The mutex is only used on Windows and Linux. On macOS, g_ipc_sync_mutex is used instead, so the unguarded declaration caused -Werror,-Wunused-variable on macOS CI builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Signal handler extracts first dash instead of last
- Removed the break statement in the loop so it continues to find the last dash, matching the strrchr behavior in sentry_backend_native.c
Or push these changes by commenting:
@cursor push cc21ef7b97
Preview (cc21ef7b97)
diff --git a/src/backends/native/sentry_crash_handler.c b/src/backends/native/sentry_crash_handler.c
--- a/src/backends/native/sentry_crash_handler.c
+++ b/src/backends/native/sentry_crash_handler.c
@@ -705,7 +705,6 @@
for (const char *p = shm_id_src; *p; p++) {
if (*p == '-') {
shm_id = p + 1;
- break;
}
}This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
The loop had a `break` that stopped at the first '-', which worked
for Linux's "/s-{id}" but gave "shm-{id}" on macOS's
"{tmpdir}/.sentry-shm-{id}". Removing the break lets it find the
last hyphen and extract just the hex ID.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
POSIX_SPAWN_CLOEXEC_DEFAULT closes all fds including stdin/stdout/ stderr. Without valid std fds, the daemon's fopen() for the log file would get fd 0, which is then destroyed by the daemon's own close(STDIN_FILENO). Pre-opening /dev/null on fds 0-2 via spawn file actions ensures the log file gets a safe fd number. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
If the caller closed stdin/stdout/stderr before sentry_init(), the IPC pipe/shm fds could land on fd 0/1/2. The addopen for /dev/null would then overwrite them. Now we skip opening /dev/null on any fd that's already used by an IPC descriptor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 011aced. Configure here.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jpnurmi
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


macOS App Sandbox blocks sem_open(), shm_open(), and fork() in sandboxed apps, causing the native backend to fail during init.