Repository navigation
fix(macos): Intel Mac worker crashes at startup on the native process-identity query - #161876
Conversation
The Darwin libproc identity query added in #157954 runs through Koffi on arm64 and x64. The release packaging proof runs the bundled x86_64 Mac node worker under Rosetta, and in native-first mode that worker segfaults on every run once the query executes, so the 2026.9.7 x86_64 and universal macOS builds cannot be packaged. Limit the native query to arm64. Intel keeps the bounded ps path it used before the native query; arm64 keeps the faster identity reads.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 30, 2026, 9:09 AM ET / 13:09 UTC. ClawSweeper reviewWhat this changesLimits native macOS process-identity reads to arm64 and adds an x64 regression test, returning Intel Mac workers to the bounded Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 2 items remain Keep open. Current main and the published v2026.9.7 source still run the native query on x64; this focused PR addresses the reported worker crash, and the Rosetta worker results support the fix. Priority: P0 Review scores
Verification
How this fits togetherOpenClaw’s shared process-identity reader supplies process birth and parent information to lock and lifecycle checks. The macOS package verifier starts the bundled worker and checks that it becomes ready. flowchart TD
A[Mac worker starts] --> B[Process identity requested]
B --> C{CPU architecture}
C -->|arm64| D[Native macOS query]
C -->|x64| E[Bounded ps query]
D --> F[Birth and parent identity]
E --> F
F --> G[Lifecycle checks]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +3. Total +5 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Ship an x64 worker that reaches ready without the Koffi process query, while arm64 keeps native reads and existing lock identities remain compatible. Do we have a high-confidence way to reproduce the issue? Yes. The PR reports repeatable exit-139 failures from the packaged x64 worker under Rosetta, and current-main source retains the implicated x64 native path; this review did not run macOS code. Is this the best way to solve the issue? Yes. The architecture guard uses the existing bounded shell fallback at the shared reader, and the new test distinguishes it from the failing native path. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c5fb142dd49a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash auto-merge.
|
…enclaw#161876) The Darwin libproc identity query added in openclaw#157954 runs through Koffi on arm64 and x64. The release packaging proof runs the bundled x86_64 Mac node worker under Rosetta, and in native-first mode that worker segfaults on every run once the query executes, so the 2026.9.7 x86_64 and universal macOS builds cannot be packaged. Limit the native query to arm64. Intel keeps the bounded ps path it used before the native query; arm64 keeps the faster identity reads.
#165088) * fix(macos): stop Rosetta segfaults in APFS worktree and process checks Koffi enters foreign calls at the very top of its private stack, and Rosetta reads [rsp+0x18, rsp+0x20) while translating some syscalls, so thin libc wrappers called through Koffi segfault whenever the next page is unmapped. #161876 fixed the pid-alive identity query by limiting it to arm64. The APFS worktree ACL guard (getattrlist) and the Darwin process-argument reader (sysctl KERN_PROCARGS2) were still exposed. Neither has a fallback that keeps real Intel Macs working, and Intel is not affected, so both gate on Rosetta translation instead of architecture via one shared helper. Under Rosetta the APFS backend falls back to Git checkout, and the process reader throws an error naming native arm64 Node.js instead of crashing: gateway-lock keeps the owner conservatively alive and the census fails closed. Detection uses the CPU brand Rosetta reports, so these paths start no extra process. A standalone x86_64 probe on macOS 27 faults on proc_pidinfo, getattrlist and both sysctl calls with no stack headroom; native x86 never reads that memory. Both new regressions fail on main. Release note: x64 OpenClaw on Apple silicon no longer segfaults when creating APFS agent worktrees or inspecting process command lines. * fix(macos): detect Rosetta only from the Apple CPU brand The first detector treated any x64 Darwin process whose CPU brand did not start with "Intel" as translated. PR CI runs on x64 AMD Linux hosts, so tests that mock process.platform as darwin hit the new Rosetta guard and the process census failed (plugin-source-capture-legacy-ownership). Detect Rosetta positively instead: translated processes report the host's Apple CPU brand ("Apple M3 Ultra"; early Rosetta "VirtualApple"), which x86 hardware never does. Intel, AMD and unknown brands keep the existing native paths. Reproduced the CI failure locally by simulating an x64 AMD host; it passes after this change. * fix(update): keep the native arm64 hint when repair runs under Rosetta Under Rosetta the Darwin process-argument reader now fails visibly, but the handoff census replaced every error with "verify process-inspection permissions", so openclaw update repair told translated installs to fix permissions that cannot help. Keep custody uncertain (fail closed) and say to rerun update repair with native arm64 Node.js instead. Normal openclaw update does not run the census and is unchanged. Also isolate the cached Rosetta detector from the test host: caller tests mock the detector, and a table-driven owner test covers Apple, VirtualApple, Intel, AMD, empty, arm64 and Linux with fresh module instances.
openclaw#165088) * fix(macos): stop Rosetta segfaults in APFS worktree and process checks Koffi enters foreign calls at the very top of its private stack, and Rosetta reads [rsp+0x18, rsp+0x20) while translating some syscalls, so thin libc wrappers called through Koffi segfault whenever the next page is unmapped. openclaw#161876 fixed the pid-alive identity query by limiting it to arm64. The APFS worktree ACL guard (getattrlist) and the Darwin process-argument reader (sysctl KERN_PROCARGS2) were still exposed. Neither has a fallback that keeps real Intel Macs working, and Intel is not affected, so both gate on Rosetta translation instead of architecture via one shared helper. Under Rosetta the APFS backend falls back to Git checkout, and the process reader throws an error naming native arm64 Node.js instead of crashing: gateway-lock keeps the owner conservatively alive and the census fails closed. Detection uses the CPU brand Rosetta reports, so these paths start no extra process. A standalone x86_64 probe on macOS 27 faults on proc_pidinfo, getattrlist and both sysctl calls with no stack headroom; native x86 never reads that memory. Both new regressions fail on main. Release note: x64 OpenClaw on Apple silicon no longer segfaults when creating APFS agent worktrees or inspecting process command lines. * fix(macos): detect Rosetta only from the Apple CPU brand The first detector treated any x64 Darwin process whose CPU brand did not start with "Intel" as translated. PR CI runs on x64 AMD Linux hosts, so tests that mock process.platform as darwin hit the new Rosetta guard and the process census failed (plugin-source-capture-legacy-ownership). Detect Rosetta positively instead: translated processes report the host's Apple CPU brand ("Apple M3 Ultra"; early Rosetta "VirtualApple"), which x86 hardware never does. Intel, AMD and unknown brands keep the existing native paths. Reproduced the CI failure locally by simulating an x64 AMD host; it passes after this change. * fix(update): keep the native arm64 hint when repair runs under Rosetta Under Rosetta the Darwin process-argument reader now fails visibly, but the handoff census replaced every error with "verify process-inspection permissions", so openclaw update repair told translated installs to fix permissions that cannot help. Keep custody uncertain (fail closed) and say to rerun update repair with native arm64 Node.js instead. Normal openclaw update does not run the census and is unchanged. Also isolate the cached Rosetta detector from the test host: caller tests mock the detector, and a table-driven owner test covers Apple, VirtualApple, Intel, AMD, empty, arm64 and Linux with fresh module instances.
#165088) * fix(macos): stop Rosetta segfaults in APFS worktree and process checks Koffi enters foreign calls at the very top of its private stack, and Rosetta reads [rsp+0x18, rsp+0x20) while translating some syscalls, so thin libc wrappers called through Koffi segfault whenever the next page is unmapped. #161876 fixed the pid-alive identity query by limiting it to arm64. The APFS worktree ACL guard (getattrlist) and the Darwin process-argument reader (sysctl KERN_PROCARGS2) were still exposed. Neither has a fallback that keeps real Intel Macs working, and Intel is not affected, so both gate on Rosetta translation instead of architecture via one shared helper. Under Rosetta the APFS backend falls back to Git checkout, and the process reader throws an error naming native arm64 Node.js instead of crashing: gateway-lock keeps the owner conservatively alive and the census fails closed. Detection uses the CPU brand Rosetta reports, so these paths start no extra process. A standalone x86_64 probe on macOS 27 faults on proc_pidinfo, getattrlist and both sysctl calls with no stack headroom; native x86 never reads that memory. Both new regressions fail on main. Release note: x64 OpenClaw on Apple silicon no longer segfaults when creating APFS agent worktrees or inspecting process command lines. * fix(macos): detect Rosetta only from the Apple CPU brand The first detector treated any x64 Darwin process whose CPU brand did not start with "Intel" as translated. PR CI runs on x64 AMD Linux hosts, so tests that mock process.platform as darwin hit the new Rosetta guard and the process census failed (plugin-source-capture-legacy-ownership). Detect Rosetta positively instead: translated processes report the host's Apple CPU brand ("Apple M3 Ultra"; early Rosetta "VirtualApple"), which x86 hardware never does. Intel, AMD and unknown brands keep the existing native paths. Reproduced the CI failure locally by simulating an x64 AMD host; it passes after this change. * fix(update): keep the native arm64 hint when repair runs under Rosetta Under Rosetta the Darwin process-argument reader now fails visibly, but the handoff census replaced every error with "verify process-inspection permissions", so openclaw update repair told translated installs to fix permissions that cannot help. Keep custody uncertain (fail closed) and say to rerun update repair with native arm64 Node.js instead. Normal openclaw update does not run the census and is unchanged. Also isolate the cached Rosetta detector from the test host: caller tests mock the detector, and a table-driven owner test covers Apple, VirtualApple, Intel, AMD, empty, arm64 and Linux with fresh module instances. (cherry picked from commit 7f30ecb)
Related: #157954
What Problem This Solves
Fixes: the bundled x86_64 Mac node worker crashes (SIGSEGV, exit 139) at startup in native-first mode, which blocks the 2026.9.7 x86_64 and universal macOS release builds.
User Impact
The Intel/universal macOS app can be packaged again. Intel Macs use the bounded
psprocess-identity path they used through 2026.9.6; Apple silicon keeps the faster native identity reads from #157954.Why This Change Was Made
#157954 reads Darwin process identity through Koffi and
libprocon arm64 and x64. The release packaging proof runs the x86_64 worker under Rosetta on Apple-silicon runners, and there the query segfaults the worker every time it runs. The x86_64 path cannot be validated on the release infrastructure, and the pre-existingpsfallback already covers Intel, so the native query is limited to arm64.Evidence
native-first-default; 2026.9.6 passed the same proof with no Darwin Koffi usage.readDarwinNativeIdentitydisabled, 0/3 crashes and the worker reachesready.NODE_DEBUG=moduleshowskoffi.nodeloaded frompid-aliveright before the crash. Isolated x64 Koffiproc_pidinfocalls also segfault intermittently with Koffi 3.2.1 and 3.3.1.node scripts/run-vitest.mjs src/shared/pid-alive*.test.ts: 60 passed.