Skip to content

fix(rizin): abort in-flight debug session starts when the manager closes - #11020

Merged
morluto merged 1 commit into
mainfrom
fix/rizin-abort-starts-on-close
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
fix/rizin-abort-starts-on-close

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Closing the Rizin debug session manager now aborts in-flight session starts as owner-closed, as GDB already did. Start tracking moves into OwnedDebuggerSessionRegistry, so both debuggers follow one rule.

Problem and expected behavior

RizinDebugSessionManager.closeAll() waited for in-flight starts (a counter plus waiters) but never aborted them. A start blocked in ownership preparation, spawn or the startup frame wait without a caller signal kept closeAll() waiting until the start finished on its own; if it never finished, close never returned. GdbSessionManager aborted its starts (#activeStarts map of AbortControllers) with OwnerCancellation.ownerClosed and then awaited them.

Expected: closing either manager aborts each in-flight start as owner-closed, waits for it to settle, and then closes the sessions. A caller abort that came first is still reported with the caller's reason.

Change and scope

  • OwnedDebuggerSessionRegistry.start(operation, callerSignal, run) registers a start before awaiting, relays the caller's abort, and, when the caller aborted first, rewrites a cancellation with the caller's reason (the GDB rule, now shared). abortStarts() aborts every in-flight start as owner-closed and waits for each to settle.
  • cancelledWithCallerReason moves from GdbSessionManager to the registry module; GDB imports it for its other uses.
  • GDB: private #activeStarts map and relay removed; closeAll calls abortStarts().
  • Rizin: #activeStarts counter and #startDrainWaiters removed; starts run through the registry; closeAll calls abortStarts() before closing sessions and TTY resources.
  • Architecture guard baseline: the one bindCleanupDependencies call in cancelledWithCallerReason moved with it (GdbSessionManager.ts 3 → 2, OwnedDebuggerSessionRegistry.ts 0 → 1). The total is unchanged.

Not included: Rizin still refuses a start made after closeAll began with an AnalysisInputError that names inferior_tty; GDB returns an owner-closed cancellation there. That is a separate user-visible change, proposed as a follow-up.

Scope decision: not applicable (lifecycle fix within existing boundaries; coordinator decision for W4f).

Contract and boundary impact

  • Semantic owner and earliest changed stage: OwnedDebuggerSessionRegistry now owns in-flight starts (relay, owner-closed abort, drain, caller-reason precedence). GDB's and Rizin's local copies are removed.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: none changed. A Rizin start interrupted by shutdown now returns AnalysisCancelledError (owner-closed) instead of running to completion.
  • Provider, bridge, target-format, or platform compatibility: none. Persistent sessions remain Linux-only.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: the start signal reaches spawnOwnedProviderProcess only for pre-spawn ownership inspection, so a session's process lifetime is not tied to it.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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: RizinDebugSessionReviewRegressions.test.ts › "aborts an in-flight Rizin start as owner-closed when the manager closes". Its spawn waits until the start is aborted. closeAll() must return, and the start must report AnalysisCancelledError with cause OwnerCancellation.ownerClosed.
  • Base reproduction: with src/rizin/RizinDebugSessionManager.ts from origin/main, the test times out (closeAll never returns, and the afterEach hook times out too). With this change it passes.
  • Lifecycle regressions: cancellation during start (owner close) for Rizin. The existing GDB tests for caller abort during start cleanup and owner-close during start still pass.
  • Remaining proof gaps: no real Rizin or GDB run; tests use fake spawners. Persistent sessions are Linux-only, and these tests ran on macOS with platform: "linux" injected.

Validation performed

  • npx vitest run --project boundary tests/boundary/providers/RizinDebugSessionReviewRegressions.test.ts tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/providers/RizinDebugSessionAdmission.test.ts tests/boundary/providers/RizinTtyCleanup.test.ts: 4 files, 228 passed, 2 skipped.
  • Same Rizin test file with the old Rizin manager: the new test fails (timeout).
  • npm run check:fast: passed.
  • node scripts/verify/architecture-guards.mjs: passed (after the baseline move above).
  • npx oxfmt --check on the changed files: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none. No real Rizin or GDB, and no Linux host.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: shutdown now ends pending Rizin starts sooner. Processes those starts already spawned go through the existing start-failure finalization.

Author readiness

Human owner:

  • 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.

OwnedDebuggerSessionRegistry now owns in-flight starts: it relays the
caller's abort, aborts each start as owner-closed on close and waits for it,
and reports the caller's reason when the caller aborted first. GDB's private
start map and Rizin's counter-and-waiters drain are removed; Rizin's closeAll
previously waited for a start without aborting it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T10:17:17.670628Z f0da863 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable issue was established.

Summary

Moves in-flight start tracking into OwnedDebuggerSessionRegistry. Rizin shutdown now aborts pending starts before closing sessions and TTY resources; GDB uses the same shared path.

  • Closing either debugger manager aborts active starts before cleanup.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Manager accepts a start"] --> B["Registry records its controller"]
  B --> C["Start runs with the owned signal"]
  D["Manager closes"] --> E["Block new starts"]
  E --> F["Abort tracked starts"]
  F --> G["Wait for starts and their cleanup"]
  C --> G
  G --> H["Close retained sessions and resources"]
Loading

Reviews (1) · Last reviewed commit: "fix(rizin): abort in-flight debug sessio..." · Reviewed by Greptile

@morluto
morluto merged commit e9f9d8b into main Nov 15, 2026
7 checks passed
@morluto
morluto deleted the fix/rizin-abort-starts-on-close branch November 15, 2026 10:21
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: rizin Analysis provider / engine: rizin labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: rizin Analysis provider / engine: rizin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant