patches/macos-sandbox-crash-fix.README.md
Fixes a crash on macOS where Camoufox segfaults during content process launch due to MOZ_CRASH being triggered when GetRepoDir() or GetObjDir() fail in non-packaged builds.
In CacheSandboxParams(), the code attempts to get repository and object directory paths for sandbox whitelisting in non-packaged builds:
if (!mozilla::IsPackagedBuild()) {
rv = nsMacUtilsImpl::GetRepoDir(getter_AddRefs(repoDir));
if (NS_FAILED(rv)) {
MOZ_CRASH("Failed to get path to repo dir"); // ← CRASH HERE
}
// ...
}
These functions (GetRepoDir and GetObjDir) read paths from the .app bundle's Info.plist file. In cross-compiled builds or unusual build configurations, these plist keys may not exist, causing the functions to fail and trigger MOZ_CRASH.
MAC_DEV_REPO_KEY, MAC_DEV_OBJ_KEY)IsPackagedBuild() may incorrectly return falseWhen any of these occur, the code crashes instead of gracefully handling the missing paths.
Changed the code from crashing on failure to logging a warning and continuing without those sandbox paths:
if (NS_SUCCEEDED(rv)) {
nsCString repoDirPath;
(void)repoDir->GetNativePath(repoDirPath);
info.testingReadPath3 = repoDirPath.get();
} else {
NS_WARNING("Failed to get repo dir path for sandbox, skipping testingReadPath3");
}
Since testingReadPath3 and testingReadPath4 are optional sandbox parameters (only used for whitelisting in development builds), it's safe to skip them if they can't be determined.
dom/ipc/ContentParent.cpp: Changed MOZ_CRASH to NS_WARNING for GetRepoDir() and GetObjDir() failuresmacOS only (wrapped in #if defined(XP_MACOSX) && defined(MOZ_SANDBOX))
Apply after the Playwright patches (0-playwright.patch, 1-leak-fixes.patch) in the build sequence.
The fix can be verified by:
MOZ_DISABLE_CONTENT_SANDBOX=1about:processestestingReadPath3 and testingReadPath4IsPackagedBuild() check