Skip to content

fix(supervisor): service-child anchors abort on Node 26 when stdin is /dev/null - #187803

Merged
RomneyDa merged 1 commit into
mainfrom
fix/anchor-release-file-stdin
Oct 29, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/anchor-release-file-stdin

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

Related: #187516

What Problem This Solves

Fixes: on Node 26, a service-child group anchor whose stdin is /dev/null or a regular file can abort with SIGABRT during retirement, before it sends its closing receipt.

User Impact

User impact: service-child anchors retire cleanly on Node 26 whatever their stdin is. In the Gateway's production launch path, anchors get a pipe as stdin whenever input is relayed, so no Gateway failure has been observed. This removes a latent abort and fixes a Node 26-only test failure on release/2026.10.10.

Why This Change Was Made

Node 26 closes fd 0 when it destroys a stdin fs.ReadStream over /dev/null or a file. The next libuv handle can then be given fd 0, and libuv's uv__close asserts fd > STDERR_FILENO when it closes that handle. The anchor still called process.stdin.destroy() in finish() and in stopInput(). Both calls now use releaseProcessStdin(), the owner added in #187516. It leaves file-backed stdin open and still releases pipes, sockets and TTYs.

On release/2026.10.10, the macOS process census still runs spawnSync("/bin/ps") after stopInput(). When the test fixture spawns the anchor with stdio[0]: "ignore", the anchor aborts inside SyncProcessRunner::CloseHandlesAndDeleteLoop -> uv__close. On main the failure doesn't show because the macOS census became native in #175368, which removed that sync spawn. The anchor hazard is still on main.

Evidence

  • New regression test keeps /dev/null stdin on fd 0 through retirement. It starts an anchor with /dev/null stdin, and a preload runs spawnSync at beforeExit.
    • Node 26.12.1 without the fix: expected { code: null, signal: 'SIGABRT' } to deeply equal { code: 0, signal: null }
    • Node 26.12.1 with the fix: passes
  • pnpm test on the anchor retirement, input-lifetime, deadline and preparation tests plus release-stdin.test.ts: 37/37 pass on Node 26.12.1 and on Node 24.22.1.
  • pnpm check:changed: typecheck, lint and format pass. The dead-export scan fails on main on unrelated files (scribes-state.ts, delivery-queue-storage.ts, session-delivery-queue-storage.ts, schtasks...test-support.ts, gateway-restart.test-support.ts). This diff doesn't touch them.
  • macOS crash report of the abort on the release head: abort <- __assert_rtn <- uv__close <- uv__loop_close <- node::SyncProcessRunner::CloseHandlesAndDeleteLoop.

@clawsweeper

clawsweeper Bot commented Oct 29, 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR uses the shared stdin-release helper at both service-child anchor retirement points to preserve file-backed fd 0 on Node 26.

Example: A Node 26.12.1 anchor starts with /dev/null stdin and performs a synchronous spawn during retirement.

  • Before: Destroying stdin closes fd 0, allowing libuv to reuse it and abort with SIGABRT.
  • After: The anchor leaves fd 0 open and exits with code 0.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and appears correct; supplied behavioral validation is a real-process regression harness rather than shipped-entry-point proof.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied evidence covers the actual anchor process with /dev/null stdin, an injected synchronous spawn, and reported Node 26 red/green retirement results.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A file-backed stdin can cause a Node 26 service-child anchor to abort instead of retiring cleanly.
Reason: The maintainer-authored repair addresses a demonstrated runtime failure using an already merged shared owner and preserves ordinary pipe behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a remaining stdin-retirement hazard on main with a focused change and a meaningful regression test; no actionable patch defects were found.

Priority: P2
Reviewed head: ef000d7f29eafc5ca75b698f70a4878be2777cd3

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied evidence exercises the real anchor through a test fixture rather than a shipped Gateway or CLI flow.
Agent review details

How this fits together

The process supervisor launches an anchor that relays child input and output, observes descendant cleanup, and reports retirement over a private control channel.

flowchart TD
  A[Supervisor host] --> B[Service child anchor]
  B --> C[Command process]
  C --> D[Cleanup and closing receipt]
  D --> E[Shared stdin release]
  E --> F[Natural anchor exit]
Loading

Technical review

Best possible solution:

Use the existing fd-type-aware stdin owner at both anchor release points while preserving the current retirement protocol.

Do we have a high-confidence way to reproduce the issue?

The added real-process regression supplies /dev/null stdin and a synchronous spawn after retirement, and the body records the intended Node 26 red/green result; this read-only review did not execute it.

Is this the best way to solve the issue?

This is the smallest complete fix: both release sites use the existing fd-type decision owner, with no new state, compatibility path, or production test seam.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e64008c7a90d.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Dallin Romney: Raw commit a3dd92b adds src/process/release-stdin.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a3dd92bd88c8; files: src/process/release-stdin.ts)
  • Peter Steinberger: Raw commit 8277325 adds src/process/supervisor/service-child-group-anchor.ts:489 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8277325ccf1b; files: src/process/supervisor/service-child-group-anchor.ts)

PR surface

Source +1, Tests +42. Total +43 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 43 1 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 46 3 +43

Root-cause cluster

Relationship: canonical
Canonical: #187803
Summary: The same file-backed fd 0 closure hazard affects distinct worker and anchor release sites, with a separate release-branch backport.

Members:

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

Labels

Label changes:

  • add P2: A demonstrated Node 26 process-retirement abort warrants repair, but the ordinary Gateway relayed-input path supplies a pipe and no user-facing Gateway failure is established.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A demonstrated Node 26 process-retirement abort warrants repair, but the ordinary Gateway relayed-input path supplies a pipe and no user-facing Gateway failure is established.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 29, 2026, 1:19 PM ET / 17:19 UTC.

@RomneyDa
RomneyDa merged commit 1840456 into main Oct 29, 2026
116 checks passed
@RomneyDa
RomneyDa deleted the fix/anchor-release-file-stdin branch October 29, 2026 22:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport #187803 from 1840456. Reuse the existing releaseProcessStdin owner from a3dd92b rather than duplicating fd-type policy.

Node 26.12.1 regression: SIGABRT on the base, clean exit after the fix. All 17 anchor retirement cases and 5 stdin helper cases pass.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit a83c3874fa3d42ff29df15bc116d233fa2385b9c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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