[PR #5382] [CLOSED] fix(gdb): keep the caller's abort reason when startup cancels #6911

Closed
opened 2026-11-01 21:44:00 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5382
Author: @XiaoBinGan
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/gdb-startup-cancellation-cause


📝 Commits (3)

  • 1628f8a fix(gdb): keep the caller's abort reason when startup cancels
  • fb53e96 fix(gdb): keep a typed startup failure when the caller aborts during cleanup
  • 5086cfd test(gdb): cover the caller reason when a cancelled stop stays incomplete

📊 Changes

3 files changed (+129 additions, -13 deletions)

View changed files

📝 src/gdb/GdbSessionManager.ts (+44 -10)
📝 tests/boundary/providers/GdbSessionManagerCoverage.test.ts (+64 -3)
➕ tests/boundary/providers/gdbStartCancellationCause.test.ts (+21 -0)

📄 Description

Summary

GdbSessionManager.start produced its AnalysisCancelledError without the caller's abort reason: an already-aborted signal returned no cause at all, and a cancellation observed after entry projected an internal AnalysisCancelledError as the cause. In-process callers therefore cannot recover the metadata they passed to abort().

Fixes #5373

Problem and expected behavior

  • Smallest trigger: manager.start(controller.signal) where signal is already aborted. The entry check returned new AnalysisCancelledError("start_gdb_session"), so error.cause was undefined and the strict-equality assertion in the report fails while no spawner is called.
  • Second trigger: cancellation after entry (spawn in flight, startup abort listener, or the post-configuration checks). Those sites also omitted the reason, and both failure projections then set cause to the internal wrapper.
  • Violated invariant: the cancellation contract in docs/tool-design.md requires the exact caller abort reason as the typed cancellation error's cause, while physical primary failures and cleanup ownership stay separate.
  • Expected: result.error.cause === reason, with the cancellation tag and the no-spawn behaviour preserved.

Change and scope

  • src/gdb/GdbSessionManager.ts carries signal.reason from every entry check (start, reservation), from the spawn failure, from the startup abort listener and from the three post-configuration abort checks.
  • Both failure projections (#stopDebuggerOnly incomplete and the confirmed-stop path) now prefer signal.reason when the caller's signal was aborted, so the reason also survives the failure wrapping. When no caller abort was observed the previous cause is kept, so a physical primary failure still wins.
  • tests/boundary/providers/gdbStartCancellationCause.test.ts adds the pre-aborted regression from the report (no spawn, cancellation tag, exact cause identity).
  • GdbSessionManagerCoverage.test.ts extends the two existing post-entry cancellation tests to abort with an explicit reason and assert the exact cause, covering both projection paths.
  • Not included: the queue-wait and active-MI abort branches the report lists as source-visible but not runtime-proven; they are unchanged here.

Contract and boundary impact

  • Semantic owner and earliest changed stage: GdbSessionManager startup cancellation projection.
  • Contribution scope fit and linked maintainer decision: not applicable — an ordinary fix inside an existing boundary.
  • CLI and MCP/tool-catalog contract: no schema, tool-catalog or payload change. Only the typed in-process cause becomes the caller's reason.
  • Provider, bridge, target-format, or platform compatibility: GDB session manager only; the Linux gate and spawn options are unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged; captured output, startup observation and cleanup ownership keep their existing fields.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged. No signal, stop or ownership decision is altered; cancellation still stops the same owned process.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: gdbStartCancellationCause.test.ts (new) plus explicit-reason assertions in the two existing post-entry cancellation tests.
  • Base reproduction or other evidence: on 0134732fc the new test fails on expect(result.error.cause).toBe(reason) — the observed shape is {"tag":"AnalysisCancelledError","exactCause":false,"causeAbsent":true,"spawns":0}, matching the report. After the change the same test passes, and the two post-entry tests fail before the projection change (expected ArtifactReaderFailure…-style identity mismatch is not involved here: they compared the internal AnalysisCancelledError to the reason) and pass after it.
  • User-visible CLI/MCP output (if applicable): none; the fix is in-process typed-result metadata.
  • Remaining proof gaps: no real GNU GDB, inferior or terminal was run; Linux is injected as in the report. The queue-wait and active-MI abort branches are left unchanged and remain unproven.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run tests/boundary/providers/gdbStartCancellationCause.test.ts — 1 passed; with the change reverted, the same file fails with the report's causeAbsent shape.
  • npx vitest run tests/boundary/providers/GdbSessionManagerCoverage.test.ts — 149 passed, including the two extended post-entry cancellation tests.
  • npx vitest run over the eight GDB suites (cli/gdbStartupCleanupCli, mcp/gdbCancellationMcp, mcp/gdbCloseDisposition, providers/GdbCommandQueue, GdbSessionManagerCoverage, GdbSessionManagers, GdbSessionReviewRegressions, plus the new file) — 188 passed. One timing-sensitive signal-file assertion in GdbSessionReviewRegressions failed once under parallel load and passed alone and on rerun.
  • npm run format:check — all matched files use the correct format.
  • npm run verify:test-discovery — all 1720 test files discovered exactly once.
  • npm run typecheck — no diagnostic in the changed files; the only errors come from this checkout's install predating the @bufbuild/protobuf dependency on current main.
  • npm run lint — 0 errors, module boundaries resolved in 2262 files.

Compatibility, safety, and release

  • Breaking changes or migration steps: the typed cause for a cancelled startup changes from undefined/internal wrapper to the caller's reason, which is the documented contract. Callers that inspected the wrapper can read signal.reason directly.
  • Real Hopper/Ghidra, browser, or OS coverage: none claimed; no real debugger or target.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; no spawn, signal or ownership behaviour changes.

Note: an independent PR (#5374) targets the same report.

Author readiness

Human owner: @XiaoBinGan

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5382 **Author:** [@XiaoBinGan](https://github.com/XiaoBinGan) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/gdb-startup-cancellation-cause` --- ### 📝 Commits (3) - [`1628f8a`](https://github.com/morluto/rea/commit/1628f8a853475a9e807e9e67aae091b0da480ff2) fix(gdb): keep the caller's abort reason when startup cancels - [`fb53e96`](https://github.com/morluto/rea/commit/fb53e96026b998926bc0140ef9307e5a86bcafc5) fix(gdb): keep a typed startup failure when the caller aborts during cleanup - [`5086cfd`](https://github.com/morluto/rea/commit/5086cfdef1a2c4791b40900a3d536d761d5c2e02) test(gdb): cover the caller reason when a cancelled stop stays incomplete ### 📊 Changes **3 files changed** (+129 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/gdb/GdbSessionManager.ts` (+44 -10) 📝 `tests/boundary/providers/GdbSessionManagerCoverage.test.ts` (+64 -3) ➕ `tests/boundary/providers/gdbStartCancellationCause.test.ts` (+21 -0) </details> ### 📄 Description ## Summary `GdbSessionManager.start` produced its `AnalysisCancelledError` without the caller's abort reason: an already-aborted signal returned no `cause` at all, and a cancellation observed after entry projected an internal `AnalysisCancelledError` as the cause. In-process callers therefore cannot recover the metadata they passed to `abort()`. Fixes #5373 ## Problem and expected behavior - Smallest trigger: `manager.start(controller.signal)` where `signal` is already aborted. The entry check returned `new AnalysisCancelledError("start_gdb_session")`, so `error.cause` was `undefined` and the strict-equality assertion in the report fails while no spawner is called. - Second trigger: cancellation after entry (spawn in flight, startup abort listener, or the post-configuration checks). Those sites also omitted the reason, and both failure projections then set `cause` to the internal wrapper. - Violated invariant: the cancellation contract in `docs/tool-design.md` requires the exact caller abort reason as the typed cancellation error's cause, while physical primary failures and cleanup ownership stay separate. - Expected: `result.error.cause === reason`, with the cancellation tag and the no-spawn behaviour preserved. ## Change and scope - `src/gdb/GdbSessionManager.ts` carries `signal.reason` from every entry check (start, reservation), from the spawn failure, from the startup abort listener and from the three post-configuration abort checks. - Both failure projections (`#stopDebuggerOnly` incomplete and the confirmed-stop path) now prefer `signal.reason` when the caller's signal was aborted, so the reason also survives the failure wrapping. When no caller abort was observed the previous cause is kept, so a physical primary failure still wins. - `tests/boundary/providers/gdbStartCancellationCause.test.ts` adds the pre-aborted regression from the report (no spawn, cancellation tag, exact cause identity). - `GdbSessionManagerCoverage.test.ts` extends the two existing post-entry cancellation tests to abort with an explicit reason and assert the exact cause, covering both projection paths. - Not included: the queue-wait and active-MI abort branches the report lists as source-visible but not runtime-proven; they are unchanged here. ## Contract and boundary impact - Semantic owner and earliest changed stage: `GdbSessionManager` startup cancellation projection. - Contribution scope fit and linked maintainer decision: not applicable — an ordinary fix inside an existing boundary. - CLI and MCP/tool-catalog contract: no schema, tool-catalog or payload change. Only the typed in-process `cause` becomes the caller's reason. - Provider, bridge, target-format, or platform compatibility: GDB session manager only; the Linux gate and spawn options are unchanged. - Evidence, artifact, provenance, or reconstruction contract: unchanged; captured output, startup observation and cleanup ownership keep their existing fields. - Target selection, authority, upstream behavior, and cleanup details: unchanged. No signal, stop or ownership decision is altered; cancellation still stops the same owned process. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). - [ ] Read existing files or captured data. - [x] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `gdbStartCancellationCause.test.ts` (new) plus explicit-reason assertions in the two existing post-entry cancellation tests. - Base reproduction or other evidence: on `0134732fc` the new test fails on `expect(result.error.cause).toBe(reason)` — the observed shape is `{"tag":"AnalysisCancelledError","exactCause":false,"causeAbsent":true,"spawns":0}`, matching the report. After the change the same test passes, and the two post-entry tests fail before the projection change (`expected ArtifactReaderFailure…`-style identity mismatch is not involved here: they compared the internal `AnalysisCancelledError` to the reason) and pass after it. - User-visible CLI/MCP output (if applicable): none; the fix is in-process typed-result metadata. - Remaining proof gaps: no real GNU GDB, inferior or terminal was run; Linux is injected as in the report. The queue-wait and active-MI abort branches are left unchanged and remain unproven. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run tests/boundary/providers/gdbStartCancellationCause.test.ts` — 1 passed; with the change reverted, the same file fails with the report's `causeAbsent` shape. - `npx vitest run tests/boundary/providers/GdbSessionManagerCoverage.test.ts` — 149 passed, including the two extended post-entry cancellation tests. - `npx vitest run` over the eight GDB suites (`cli/gdbStartupCleanupCli`, `mcp/gdbCancellationMcp`, `mcp/gdbCloseDisposition`, `providers/GdbCommandQueue`, `GdbSessionManagerCoverage`, `GdbSessionManagers`, `GdbSessionReviewRegressions`, plus the new file) — 188 passed. One timing-sensitive signal-file assertion in `GdbSessionReviewRegressions` failed once under parallel load and passed alone and on rerun. - `npm run format:check` — all matched files use the correct format. - `npm run verify:test-discovery` — all 1720 test files discovered exactly once. - `npm run typecheck` — no diagnostic in the changed files; the only errors come from this checkout's install predating the `@bufbuild/protobuf` dependency on current main. - `npm run lint` — 0 errors, module boundaries resolved in 2262 files. ## Compatibility, safety, and release - Breaking changes or migration steps: the typed `cause` for a cancelled startup changes from `undefined`/internal wrapper to the caller's reason, which is the documented contract. Callers that inspected the wrapper can read `signal.reason` directly. - Real Hopper/Ghidra, browser, or OS coverage: none claimed; no real debugger or target. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; no spawn, signal or ownership behaviour changes. Note: an independent PR (#5374) targets the same report. ## Author readiness Human owner: @XiaoBinGan - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:44:00 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6911
No description provided.