Skip to content

fix(macos): Intel Mac worker crashes at startup on the native process-identity query - #161876

Merged
steipete merged 1 commit into
mainfrom
fix/darwin-pid-identity-arm64-only
Sep 30, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/darwin-pid-identity-arm64-only

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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 ps process-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 libproc on 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-existing ps fallback already covers Intel, so the native query is limited to arm64.

Evidence

  • Release-ops runs 36659957509 and 36695080682: every x86_64 worker proof (x86_64 and universal variants) exits 139 in native-first-default; 2026.9.6 passed the same proof with no Darwin Koffi usage.
  • Local repro under Rosetta with the 2026.9.7 worker package (x64 Node 24.19.0 and 24.21.0): native-first worker SIGSEGV 3/3; with only readDarwinNativeIdentity disabled, 0/3 crashes and the worker reaches ready. NODE_DEBUG=module shows koffi.node loaded from pid-alive right before the crash. Isolated x64 Koffi proc_pidinfo calls also segfault intermittently with Koffi 3.2.1 and 3.3.1.
  • New x64 test fails on the old code and passes now; node scripts/run-vitest.mjs src/shared/pid-alive*.test.ts: 60 passed.
  • Gap: not run on physical Intel hardware; the change returns Intel to the 2026.9.6 behavior instead.

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.
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 30, 2026, 9:09 AM ET / 13:09 UTC.

ClawSweeper review

What this changes

Limits native macOS process-identity reads to arm64 and adds an x64 regression test, returning Intel Mac workers to the bounded ps path.

Regression provenance

Possible 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
Reviewed head: 96c6cf0db1d2e37b77b322c5fd95cc674cee73c9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair has credible worker-level before-and-after evidence and a targeted regression test, with a small test-cost documentation gap.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed shared reader skips Koffi on x64. The pinned PR body reports packaged x64 worker starts under Rosetta changing from 3/3 exit-139 failures to 3/3 ready results with that native read disabled; the new unit test is supplemental. Physical Intel and an exact-head package run are not shown. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed shared reader skips Koffi on x64. The pinned PR body reports packaged x64 worker starts under Rosetta changing from 3/3 exit-139 failures to 3/3 ready results with that native read disabled; the new unit test is supplemental. Physical Intel and an exact-head package run are not shown. No stored-data contract changes.
Evidence reviewed 9 items Introduced guard: The PR excludes x64 before Koffi is loaded, while retaining the arm64 native path.
Existing fallback: A failed or skipped native read reaches a /bin/ps query with a bounded timeout.
Regression coverage: The new x64 case checks the shell result and verifies that Koffi is not loaded. The PR body reports 60 focused tests passing, without a measured test-file wall time.
Findings 1 actionable finding [P3] Record the changed test's measured cost
Security None None.

How this fits together

OpenClaw’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]
Loading

Before merge

  • Record the changed test's measured cost (P3) - The new x64 regression case changes this test file, but the PR Evidence section gives only a pass count. Root AGENTS.md requires its measured single-worker wall time and CI seconds once available so maintainers can assess recurring test cost; add those figures to the PR body.
  • Complete next step (P2) - Add the changed test file’s measured single-worker wall time and available CI seconds to the PR Evidence section.

Findings

  • [P3] Record the changed test's measured cost — src/shared/pid-alive.native.test.ts:56
Agent review details

Security

None.

PR surface

Source +2, Tests +3. Total +5 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 2 +2
Tests 1 21 18 +3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 25 20 +5

Review metrics

None.

Root-cause cluster

Relationship: canonical
Canonical: #161876
Summary: This PR addresses an x64 crash on the native-query path added by a merged performance PR; the earlier PR addressed update delays.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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:

  • [P3] Record the changed test's measured cost — src/shared/pid-alive.native.test.ts:56
    The new x64 regression case changes this test file, but the PR Evidence section gives only a pass count. Root AGENTS.md requires its measured single-worker wall time and CI seconds once available so maintainers can assess recurring test cost; add those figures to the PR body.
    Confidence: 0.94

Overall correctness: patch is correct
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c5fb142dd49a.

Labels

Label changes:

  • add P0: The reported x64 worker startup crash blocks Intel and universal macOS package verification.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed shared reader skips Koffi on x64. The pinned PR body reports packaged x64 worker starts under Rosetta changing from 3/3 exit-139 failures to 3/3 ready results with that native read disabled; the new unit test is supplemental. Physical Intel and an exact-head package run are not shown. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed shared reader skips Koffi on x64. The pinned PR body reports packaged x64 worker starts under Rosetta changing from 3/3 exit-139 failures to 3/3 ready results with that native read disabled; the new unit test is supplemental. Physical Intel and an exact-head package run are not shown. No stored-data contract changes.

Label justifications:

  • P0: The reported x64 worker startup crash blocks Intel and universal macOS package verification.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed shared reader skips Koffi on x64. The pinned PR body reports packaged x64 worker starts under Rosetta changing from 3/3 exit-139 failures to 3/3 ready results with that native read disabled; the new unit test is supplemental. Physical Intel and an exact-head package run are not shown. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed shared reader skips Koffi on x64. The pinned PR body reports packaged x64 worker starts under Rosetta changing from 3/3 exit-139 failures to 3/3 ready results with that native read disabled; the new unit test is supplemental. Physical Intel and an exact-head package run are not shown. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete enabled auto-merge (squash) September 30, 2026 13:32
@steipete
steipete merged commit 3894140 into main Sep 30, 2026
206 checks passed
@steipete
steipete deleted the fix/darwin-pid-identity-arm64-only branch September 30, 2026 13:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…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.
steipete added a commit that referenced this pull request Oct 4, 2026
#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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
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.
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant