Repository navigation
fix(crash-reporting): stop claiming kills that never landed, and leave proof when the own-Chromium pid set is unreadable - #18578
Conversation
…that was already gone terminatePosixTree's default group signal swallowed every process.kill error and then recorded a self_tree_kill unconditionally, so an ESRCH — proof the group was already gone and this teardown killed nothing — still put a suspect in the five-second render-process-gone attribution window. Every sibling group-kill in the tree already records only on a proven signal: terminateDedicatedPosixGroup in this same file, forceKillPosixPtyProcessGroups, and the claude account-login teardown. This makes the outlier match them.
Disposition of the seven bot findings on #18367#18367 merged early (
1 / 6 — correct, fixed. pullfrog's diagnosis is exact: the default 3 / 5 — refuted on timing. These are the Windows
The POSIX arm is different only because 2 — the prescription is refuted, but it pointed at a real gap, now closed. Failing closed would refuse every tree kill on that host. Since a refusal only kills the root through its child handle, that orphans the descendants of every PTY, git, codex and notebook teardown for as long as the fault lasts — and on The part of the finding that was right: the empty set was byte-identical to "this host has no Chromium", so the fail-open was invisible in a field bundle — nobody could tell the gate had stopped being able to judge. This PR adds a coalesced durable 4 / 7 — real, but not a regression. Both describe the check-to-use window on a pid-addressed kill. Verified pre-existing: Unrelated to the bots: #18459 (the rest of the #18367 remediation) was red on |
…t be read `readOrcaChromiumProcessPids` returns an empty set when `getAppMetrics()` throws, which is the right decision — refusing every kill would orphan every PTY, git, codex and notebook tree main tears down, and on main a refusal from `killSourceControlAgentProcess` releases the managed-home lock with the agent still alive. But the empty set was byte-identical to "no Chromium on this host", so the fail-open was invisible in a field bundle. Keeps the decision, adds a coalesced durable `own_chromium_pids_unreadable` crumb so the two cases are distinguishable. Coalesced because the gate reads this set on every tree kill.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe POSIX teardown path now propagates process-group signal errors and records self-initiated kill attribution only after successful signaling. Tests cover absent and reachable groups. Chromium metrics read failures now create coalesced durable crash breadcrumbs while returning an empty set and preserving fail-open kill admission. A new test verifies these behaviors and records the original error cause. Merge Risk: ⚪ Minimal · up to Process-teardown crash attribution is made more accurate, and unreadable Chromium metrics now leave durable diagnostic context without changing termination admission. No concrete current-head merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed scope, rationale, testing evidence, trade-offs, and follow-ups. However, it does not use most required template sections, including Linked Issue with a Fixes reference, Visual Proof or N/A, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Add the missing required template sections. Include a
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Disposition of the seven bot findings on #18367 (all verified against Fixed here
Refuted, with reasons
Open, pre-existing, not regressions
Separately: #18459's CI was red on |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/own-chromium-tree-kill-guard.test.ts (1)
157-159: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert ring retention, not only coalescing.
The assertion at Line 157 filters for
own_chromium_pids_unreadable, so it proves only that repeated failures produce one matching breadcrumb. It does not prove that existing breadcrumbs remain in the shared 30-entry ring. Populate the ring near capacity, exercise failures across the coalescing interval, and assert that a sentinel breadcrumb remains.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: efa2de29-a6ce-4311-8b22-eec51bdf9752
📒 Files selected for processing (4)
src/main/codex/codex-app-server-process-teardown.test.tssrc/main/codex/codex-app-server-process-teardown.tssrc/main/orca-chromium-process-pids.tssrc/main/own-chromium-tree-kill-guard.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
terminatePosixTreerecords only on a proven group signal — the defaultsignalGrouplambda no longer swallowsprocess.kill(-pgid, 'SIGKILL')errors; the call is wrapped in atry/catchthat setsgroupSignalledonly on a non-throwing signal, andrecordSelfInitiatedTreeKillis gated on it. AnESRCH(group already gone) no longer credits Orca with a kill it never issued, matching theterminateDedicatedPosixGroupsibling.- Unreadable Chromium metrics now leave proof —
readOrcaChromiumProcessPidsemits a coalesced durableown_chromium_pids_unreadablecrumb whengetAppMetrics()throws, distinguishing an unreadable metrics table from the legitimate "no Chromium here" empty set, while staying deliberately fail-open. - Tests — two new tests in
codex-app-server-process-teardown.test.ts(one exercising the realprocess.killagainst an unreachable pgid, one asserting the record on a proven signal) and one inown-chromium-tree-kill-guard.test.ts(pins coalescing while still admitting the kill).
The changes are correct and minimal: termination behavior is unchanged (the wrapper still gets SIGKILL, the function still resolves true), only the breadcrumb moves. The scope of finding 1 is honestly documented (posix-process-group lands in selfInitiatedGroupKillCount, not the Windows-only selfInitiatedTreeKillCount). The fail-open rationale and the record-before-attempt decision on the Windows arms are well-reasoned. I verified the two touched suites pass locally (19 tests), and confirmed no new import cycle (durable-crash-breadcrumb was already reachable via own-chromium-tree-kill-guard).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…e proof when the own-Chromium pid set is unreadable (stablyai#18578) * fix(crash-reporting): stop the codex POSIX teardown claiming a group that was already gone terminatePosixTree's default group signal swallowed every process.kill error and then recorded a self_tree_kill unconditionally, so an ESRCH — proof the group was already gone and this teardown killed nothing — still put a suspect in the five-second render-process-gone attribution window. Every sibling group-kill in the tree already records only on a proven signal: terminateDedicatedPosixGroup in this same file, forceKillPosixPtyProcessGroups, and the claude account-login teardown. This makes the outlier match them. * fix(crash-reporting): leave proof when the own-Chromium pid set cannot be read `readOrcaChromiumProcessPids` returns an empty set when `getAppMetrics()` throws, which is the right decision — refusing every kill would orphan every PTY, git, codex and notebook tree main tears down, and on main a refusal from `killSourceControlAgentProcess` releases the managed-home lock with the agent still alive. But the empty set was byte-identical to "no Chromium on this host", so the fail-open was invisible in a field bundle. Keeps the decision, adds a coalesced durable `own_chromium_pids_unreadable` crumb so the two cases are distinguishable. Coalesced because the gate reads this set on every tree kill. * style(crash-reporting): tighten the group-signal comments to the WHY

What
Two CodeRabbit findings from #18367 that are live on
mainand are not addressed by #18459. #18367 merged early (as7b530f1eb56) before its own remediation round; #18459 carries the choke-point work, but neither of these two.1.
terminatePosixTreeclaimed a group kill that never landed. The codex app-server teardown's snapshot path recorded aself_tree_killbreadcrumb even when the group signal proved the group was already gone. Its defaultsignalGroupswallowed everyprocess.kill(-pgid, 'SIGKILL')error and therecordSelfInitiatedTreeKillcall sat unconditionally below it, so anESRCH— positive proof that this teardown killed nothing — still credited Orca with a group kill inside the five-secondrender-process-goneattribution window that #18367 exists to make decidable.2. An unreadable Chromium pid set was indistinguishable from "no Chromium here".
readOrcaChromiumProcessPidsreturns an empty set whengetAppMetrics()throws. That decision is kept (see Trade-offs — failing closed is much worse), but the empty set was byte-identical to the legitimate Node-host case, so the fail-open left no trace in a field bundle. Now it emits a coalesced durableown_chromium_pids_unreadablecrumb.Two other CodeRabbit findings on #18367 are REFUTED here, not fixed —
own-chromium-tree-kill-guard.ts:35/process-tree-termination.ts:89("record accepted kills only aftertaskkillsucceeds") and the "fail closed" half oforca-chromium-process-pids.ts:34. Both are declined on evidence, and complying with either would introduce a worse bug than the one it fixes. Reasoning and numbers are in Refuted findings below. Do not read this PR as "all bot comments addressed".Finding 1 is the one member of the "record before the kill is proven" family that is both wrong and cheaply fixable: the signal is synchronous, so success is knowable at zero cost, and three siblings already do it correctly.
Fix evidence
Finding 1 is not a new convention — it makes the outlier match the three group-kill sites that already record only on a proven signal:
terminateDedicatedPosixGroup(same file,codex-app-server-process-teardown.ts:29)catchreturns before the record, commented "Outside the try: that catch is the ESRCH contract, not a breadcrumb handler"forceKillPosixPtyProcessGroups(pty/posix-pty-process-groups.ts:130)isProcessAlreadyGoneskips the recordclaude-login-process-termination.ts:79signaledGroupflagterminatePosixTree(codex-app-server-process-teardown.ts:139)does not claim a snapshot group that was already gonedrives the production default, not an injected seam — the swallow being tested lives in the default lambda, so an injected throwing dep would not reach it. It uses pgid2_147_483_647(abovepid_maxon every supported POSIX host) soprocess.kill(-pgid)raises a realESRCH.RED without the production hunk. Run in a throwaway detached worktree with only
src/main/codex/codex-app-server-process-teardown.tsrestored to itsorigin/maincontent, so nothing else could perturb the result:RED without the finding-2 hunk, same method on
src/main/orca-chromium-process-pids.ts:GREEN with both, plus the surrounding suites:
ELI5
When Orca force-kills a group of processes it writes a note: "I did this." If a renderer dies right after, those notes are the list of suspects the crash report prints.
Finding 1: this path wrote the note even when the group had already exited and Orca's signal bounced off nothing — a suspect that was never at the scene. Now the note is only written when the signal actually reached something.
Finding 2: before killing anything, Orca asks Electron "which processes are my own windows?" so it never kills one by accident. If that question fails, Orca gets back an empty answer — which looks exactly like the honest answer on a machine that has no windows at all. Orca still proceeds (refusing everything would strand real processes), but it now writes down that the question failed, so nobody later reads "no windows here" and believes it.
Honest scope on finding 1: this is a POSIX group kill, so it lands in
selfInitiatedGroupKillCountand theselfInitiatedKillsstring, not inselfInitiatedTreeKillCount— the pid-addressed, Windows-only field that actually decides whether arender-process-gonewas Orca's. A process group cannot contain a Chromium process Orca did not put there, so this can never have caused a wrong verdict; it added a phantom entry to the evidence list a human reads next to it. Worth fixing because the list is the artifact, and because three sibling call sites already get this right — not because it was masking a crash.Refuted findings
"Record accepted kills only after
taskkillsucceeds" (coderabbitown-chromium-tree-kill-guard.ts:35,process-tree-termination.ts:89) — refuted.The record is read at
render-process-gonetime byfindSelfInitiatedTreeKills, over[-SELF_TREE_KILL_LOOKBACK_MS, +SELF_TREE_KILL_LOOKAHEAD_MS]=[-5000ms, +250ms]. The kill causes the death, so the death arrives beforetaskkill.exeexits.terminateWindowsProcessTreetolerates that exit forWINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS= 5000 ms by design. Recording on the success callback therefore stampsatup to 5000 ms aftergoneAt— outside a 250 ms lookahead — so the crash report would say "no self-initiated kill" for a kill Orca definitely issued.That is a false negative in exactly the #10680 scenario the feature was built for, which is strictly worse than the bounded false positive being guarded against. The bot is optimising the cheap error at the cost of the expensive one. Additionally, "each caller's confirmed-success path" does not exist for several gated sites —
codex-accounts/service.ts(execFileSync), the browser-route probes (spawnSync), and the fire-and-forgetspawnarms inprecheck-runner.ts/ipc/notebook.ts/git/command-runner— so complying would mean restructuring five teardowns to buy a worse signal.POSIX is the exception, and that is the whole of finding 1 above:
process.kill(-pgid)is synchronous, so there is no latency to lose and no reason to record early."Fail closed when Chromium metrics cannot be read" (coderabbit
orca-chromium-process-pids.ts:34) — refuted; the epistemic half taken.A refusal is not free.
terminateWindowsProcessTreeresolves without killing on refusal, andkillSourceControlAgentProcess(text-generation/source-control-local-process.ts:32-34onmain) returns that straight to a caller that then runsmarkProcessClosedand releases the managed-home lock with the agent still alive. Failing closed would convert one transientgetAppMetrics()throw into refusing every pid-addressed tree kill in main — orphaning every PTY, git, codex and notebook tree on Windows and tripping that lock bug — to prevent a hypothetical.getAppMetrics()is a synchronous in-process Electron call; a throw means main is already broken.What the bot was actually right about is that the failure was invisible: an empty set from a throw was byte-identical to the legitimate "no Chromium on this host". That half is fixed (finding 2).
Still open, pre-existing, not regressions: identity-bound termination (Job Object / handle) instead of a pid — coderabbit
own-chromium-tree-kill-guard.ts:34andprocess-tree-termination.ts:38. Accurate, unfixed onmainand unfixed in #18459. The PID check-to-use window predates #18367, which narrows rather than closes it. Tracked as the non-Chromium half of #10680; out of scope for a diagnostics fix.Trade-offs
getAppMetrics()throw. That is worse, and concretely so: a refusal is not free.terminateWindowsProcessTreeresolves without killing on refusal, andkillSourceControlAgentProcess(text-generation/source-control-local-process.ts:32-34) returns that straight to a caller that then runsmarkProcessClosedand releases the managed-home lock with the agent still alive. Failing closed would trade one unreadable metrics table for every PTY, git, codex and notebook tree in main leaking at once, plus that lock bug — to prevent a hypothetical.getAppMetrics()is a synchronous in-process Electron call; a throw there means main is already broken. The crumb answers the reviewer's real complaint (we could not tell) without buying the leak.taskkill.exeis an out-of-process spawn whose exit can trail the renderer's death by more thanSELF_TREE_KILL_LOOKAHEAD_MS(250 ms) — routinely so under EDR, and by design up toWINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS(5 s) when it wedges. Recording on the success callback would move the crumb outside the window for the kills that did land, converting a bounded false-positive into a false-negative in exactly the scenario the feature was built for. Several gated sites (codex-accounts/service.tsexecFileSync, the browser-routespawnSyncprobes, the fire-and-forgetspawnarms) have no confirmed-success path to move it to without restructuring five teardowns. POSIX is different only because the signal is synchronous.ESRCH.terminateDedicatedPosixGroupdistinguishesESRCHbecause it uses it as a return value; here the value is only "did we kill something", and anEPERMis equally not-a-kill. This also keeps the arm safe if it ever runs on a host whereprocess.kill(-pgid)is unsupported.SIGKILLand the function still resolvestrue. Only the breadcrumb moved. Confirmed by the adjacent assertions in the new tests (target.killlast called withSIGKILL, resolvestrue).Adversarial review
process.killdelivered no signal to any process — the group either did not exist or we lacked permission. Neither is a kill.scopeisposix-process-groupand itspidissnapshot.rootPgid; claiming that specific mechanism when it did not fire is the defect.2_147_483_647exceedspid_maxon Linux (2^22 ceiling) and macOS (99998), soESRCHis structural, not probabilistic. This spec is not in thepackage (windows)lane's list, so that arm is Linux/macOS-verified only; the fix intentionally does not branch on the error code, so any throw on any host takes the same path.readOrcaChromiumProcessPids()is called byadmitSelfInitiatedTreeKilloutside its owntry, so a throw from the breadcrumb path would propagate into the caller and turn an admitted kill into a thrown one. The recorder is therefore wrapped in its owntry/catch, matching the existing "diagnostics must never fail a termination" rule inprocess-tree-kill-observer.ts.own-chromium-tree-kill-guard.tsalready imports bothorca-chromium-process-pidsand (transitively, viaself-initiated-tree-kill-log)durable-crash-breadcrumb, so the daemon/orcadpaths already carry it.tsc -p config/tsconfig.node.jsonis clean.node:child_processimport, no new raw recursiverm, nomax-lineschange, and no breadcrumb-name registry exists that would need updating.Follow-ups
signalProcessTree(src/shared/child-process/process-tree-termination.ts), where the admit-and-record seam necessarily fires beforeprocess.kill(-pid). Splitting admit from record there is a larger change to the shared gate and belongs with fix(crash-reporting): make the own-Chromium gate a real choke point, and stop a refusal leaking the root #18459, not here.taskkill /pidsites, the refusal→killRootfallback, and scope-aware ring eviction).process-tree-termination.ts:38andown-chromium-tree-kill-guard.ts:34. Pre-existing, tracked as the non-Chromium half of Windows PTY teardown: ancestryownis not true root identity (PID recycle into Orca tree) #10680.