Skip to content

fix(rizin): preserve stopped session diagnostics - #8025

Closed
Nikhila-Dhevi-R wants to merge 4 commits into
morluto:mainfrom
Nikhila-Dhevi-R:codex/issue-8024-rizin-session-diagnostics
Closed

Nikhila-Dhevi-R wants to merge 4 commits into
morluto:mainfrom
Nikhila-Dhevi-R:codex/issue-8024-rizin-session-diagnostics

Conversation

@Nikhila-Dhevi-R

@Nikhila-Dhevi-R Nikhila-Dhevi-R commented Oct 29, 2026 •

Copy link
Copy Markdown

Fixes #8024

After a Rizin protocol/output limit stops a session, later commands now return the retained stop reason and session status exposes closed_reason. Cleanup synchronization and successful automatic cleanup retries preserve that diagnosis until explicit close.

Failed startups are tracked separately from successfully published sessions. Their records are removed after cleanup succeeds, releasing capacity even when REA_DEBUGGER_MAX_SESSIONS=1. This addresses the failed-start slot review finding. The MCP regression now correctly expects cleanup_incomplete for the first failed cleanup, then capability_unavailable after recovery.

Validation

  • Added manager coverage for failed startup, retained cleanup ownership, recovery, and replacement startup at capacity one.
  • Added MCP coverage for retained command errors and status after automatic cleanup.
  • Current follow-up: formatting and diff checks passed; targeted lint exited successfully with existing manager warnings.
  • Direct Vitest run of the two affected test files: 1 passed, 18 skipped on Windows. The Linux/TTY regressions have not been executed locally.
  • Earlier full local fast checks encountered memory exhaustion; the focused wrapper also required missing packaged Windows native controls.
  • GitHub CI, CodeQL and title workflows on the previous head were action_required (maintainer approval), not failed test runs. Full CI results remain unverified.

Author readiness

Human owner: @Nikhila-Dhevi-R

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T11:55:19.546005Z
We couldn’t complete this review. Comment @codex review to try again.
61821cb 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; both numbered previous findings are fixed and no new blocking issue was found.

Summary

Preserves Rizin stop reasons across cleanup recovery while releasing session slots held by failed starts.

  • Rizin sessions keep their stop reason after cleanup recovers.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Rizin startup] --> B{Startup succeeds?}
  B -->|Yes| C[Publish session ID]
  B -->|No| D[Keep failed-start owner while cleanup is pending]
  C --> E[Command stops session]
  E --> F[Save stop reason]
  D --> G[Retry cleanup]
  F --> G
  G --> H{Cleanup succeeds?}
  H -->|No| I[Keep owner for retry]
  H -->|Yes| J{Published session with saved reason?}
  J -->|No| K[Remove record and release slot]
  J -->|Yes| L[Keep status and typed stop error]
  L --> M[Explicit close removes record]
Loading

Reviews (4) · Last reviewed commit: "fix(rizin): release failed startup slots..." · Reviewed by Greptile

Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
@Rinkia

Rinkia commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

I tested this PR at 61821cb2a against main at 4b961e371. I used the #8024 repro: the Rizin 0.9.1 static release in a Linux x64 container, the utf8 probe, and over MCP db @ sym.stop_here, dc, px 4000000 @ obj.big, then more commands.

Call after the frame-limit stop main This PR
px 5000000, dr rip, pd 1 @ rip, dc invalid_request, "Analysis input is invalid", no details capability_unavailable, "The Rizin debug session stopped before this operation could run", reason "Rizin emitted a NUL frame exceeding the 16777216 byte (16 MiB) protocol limit". Remediation: "Close the stopped Rizin debug session and start a new session before retrying."
rizin_debug_session_status state: "closed" state: "closed", closed_reason with the same text
close_rizin_debug_session target_state: "unknown" same

That covers the first two points of #8024, and no processes are left.

Two notes:

…zin-session-diagnostics

# Conflicts:
#	src/rizin/RizinDebugSessionManager.ts
@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @Nikhila-Dhevi-R, thanks for putting this together, the fix looks useful. What's left: there is 1 unresolved review thread from Greptile, about "Cleanup erases the stop reason". Happy to get this in once that's sorted out.

Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
@CassieFox23

CassieFox23 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: On head 69b5408, the new test retains the Rizin stop reason after MCP cleanup recovery fails on Node 22, 24 and 26: it expects capability_unavailable but gets cleanup_incomplete. Two output-limit cleanup cases fail without the fix and pass with it. CI has not run yet, because CI waits for a maintainer to approve it.

Edit (8 Nov): I ran the new head, 6e469c6, in a VM, and the results are here.

I ran tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts and tests/boundary/providers/RizinDebugSessionCoverage.part3.test.ts in a VM. The red run is the same head and test files, with src/rizin/RizinDebugSessionManager.ts and src/contracts/rizinDebugToolContracts.ts swapped back to the merge base 6be6596. The merge base is the commit where the branch left main.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Head 69b5408 1 file failed, 1 passed; 1 test failed, 29 passed 1 file failed, 1 passed; 1 test failed, 29 passed 1 file failed, 1 passed; 1 test failed, 29 passed
Red run (2 source files from 6be6596) 2 files failed; 3 tests failed, 27 passed 2 files failed; 3 tests failed, 27 passed 2 files failed; 3 tests failed, 27 passed
  • The failing test is the new one, retains the Rizin stop reason after MCP cleanup recovery. It is not in the merge base 6be6596.
  • It fails the same way on all three Node versions: AssertionError: expected 'cleanup_incomplete' to be 'capability_unavailable' at tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts:185.
  • In the red run, the extra failures are recovers output-limit cleanup only after a fresh marker and inferior readback (retry=false and retry=true). So those 2 cases fail without the fix and pass with it.
  • The PR body's follow-up line for 69b5408 lists oxfmt, oxlint and git diff --check. It says manager and MCP regressions were added. It does not list a test run for this head. On Windows, it says, 42 of 43 Rizin tests were skipped.
  • On 69b5408, CI, CodeQL production and PR title are waiting for a maintainer to approve them (action_required). Greptile Review, Validate author declaration and PR readiness passed.
  • The head is 316 commits behind main b81da90. GitHub says the PR is mergeable, and its merge state is blocked.
  • One idea: check what code the MCP path returns after cleanup recovery. The new MCP test expects capability_unavailable, but this head returns cleanup_incomplete.

Not run

  • A real rizin debug session.
  • A merge with current main, b81da90.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 69b5408 / 6be6596 (merge base with main)
  • Red run: 69b5408 with the 2 changed source files from 6be6596
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0, for both trees
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part3.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: My comment above saw a failing MCP test at 69b5408. On 6e469c6, the 3 changed test files pass on all three Node versions. The new RizinDebugSessionCoverage.part1.test.ts test fails on the old source, but the MCP test passes either way.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Head 6e469c6, 3 changed test files pass: 3 files, 45 tests pass: 3 files, 45 tests pass: 3 files, 45 tests
Old src/rizin/RizinDebugSessionManager.ts, 2 test files fail: 1 failed, 18 passed fail: 1 failed, 18 passed fail: 1 failed, 18 passed
  • 6e469c6 changes three files since 69b5408: src/rizin/RizinDebugSessionManager.ts (6 lines), a new 50-line test in tests/boundary/providers/RizinDebugSessionCoverage.part1.test.ts, and tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts.
  • In the MCP test, the expected code changes from capability_unavailable to cleanup_incomplete. That is the code my comment above saw.
  • For the old-source run, I swapped src/rizin/RizinDebugSessionManager.ts back to its 69b5408 version. I ran the two test files that changed in 6e469c6.
  • The failing test is releases failed-start capacity after automatic cleanup recovery, with expected false to be true. The MCP test passed with the old source too.
  • So the new test covers the source change. The MCP test passes with or without the source change, because only its expected code changed.
  • One idea: is cleanup_incomplete the code the MCP tool should report here, or should the tool still say capability_unavailable?
  • I read CI on the head live with gh. The CI workflow run is action_required, and its check runs show no CI test jobs.
  • Greptile Review passed. Validate author declaration has one passed run and one cancelled run. The PR readiness status is success.
  • GitHub says the PR is mergeable, but its merge state is blocked.
  • The head is 322 commits behind main 88cf498.

Not run

  • A real rizin debug session.
  • A merge with current main.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head: 6e469c6; old-source run: 6e469c6 with src/rizin/RizinDebugSessionManager.ts from 69b5408
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0, for both trees
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part1.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part3.test.ts
xvfb-run -a npm run test:focused -- tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part1.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you for this fix. The same issue (#8024) is now fixed on main by #10398, which keeps stopped GDB and Rizin sessions with their closed reason so later calls report why the session stopped. Closing as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added 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

bug Something isn't working provider: rizin Analysis provider / engine: rizin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] After a Rizin debug session is stopped by its frame limit, later commands return a generic invalid-input error and status gives no reason

5 participants