[GH-ISSUE #8642] [Bug] Rizin debug session close fails when the target reads stdin, because it inherits the command stream #7501

Open
opened 2026-11-03 00:30:16 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @NeoFluxx01 on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/8642

Originally assigned to: @kaoru0822-kitauji on GitHub.

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

Process capture or runtime observation

Observed behavior

Over MCP, close_rizin_debug_session on a session started on /usr/bin/cat, which reads stdin, returns cleanup_incomplete after about 1 s: "Owned Rizin debugger inferior detach was not verified within 1000 ms". One Rizin process and one cat process stay running under the server's user. REA's own commands appear on the selected TTY: olj and !echo __REA_CLEANUP_COMPLETE_…__.

Reproduction

  1. Over MCP, call start_rizin_debug_session on /usr/bin/cat.
  2. Call close_rizin_debug_session.
  3. Observe the result above. Reproduced 3 of 3 with cat, and on sha256sum.

Expected behavior

Rizin exits and the target is detached. The target may keep running, as the tool description says.

Impact and scope

Each close on a stdin-reading target leaves one Rizin process and the target running, and the target reads REA's commands. The CLI path hangs (below). Other platforms and Rizin versions were not tested.

REA version

rea-agents 6.8.0

Runtime and platform

Node 24.22.2; Debian 13 x86-64; Rizin 0.9.1

Target and artifact context

ELF x86-64 system binaries: cat, sha256sum, yes, true

Interface

MCP; also CLI

Earliest failure stage

Cleanup, cancellation, or lifecycle

Relevant output or evidence

Target, unmodified Close
cat, 3 of 3 cleanup_incomplete, 1.0 s
sha256sum cleanup_incomplete, 1.0 s
yes, ignores stdin, still running after close clean, 0.03 s
true, exits by itself clean, 0.03 s

CLI path: rea debug-with-rizin /usr/bin/cat dr --inferior-tty <pty> --format json prints its result, then hangs. Still hung at 30 s with Rizin and cat running; with -R stdin=<tty> it exits 0 in 1.87 s. /usr/bin/true exits 0.

Analysis or suspected cause

start_rizin_debug_session passes -R stdout=<tty> -R stderr=<tty> and sends commands on stdin, without -R stdin=. In /proc, the target's fd 0 is the same socket as Rizin's fd 0. Detach resumes the target, which reads the next commands, so Rizin never answers.

Tested fix: a wrapper that adds -R stdin=<tty> and execs Rizin, set through REA_RIZIN_COMMAND. cat 3 of 3 and sha256sum close clean in 0.03 s and stay running, with nothing on the TTY. A passthrough wrapper still fails. /dev/null was not tested.

Source only: src/rizin/RizinDebugSessionManager.ts on main at 8250bf232 passes the same arguments. We did not run main.

Additional context

Also seen on: 6.7.0 carrying a local cleanup patch, so this may not be new in 6.8.0. We have not compared unpatched 6.7.0.

Related, not duplicates: #5516 changes Rizin cancellation and exit drain; #8024 covers a session stopped by its frame limit; #7143 covers cleanup_incomplete across user namespaces; closed #5277 reports a first-close failure on a short-lived target, where true closed clean here. None was tested here.

Originally created by @NeoFluxx01 on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/8642 Originally assigned to: @kaoru0822-kitauji on GitHub. ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area Process capture or runtime observation ### Observed behavior Over MCP, `close_rizin_debug_session` on a session started on `/usr/bin/cat`, which reads stdin, returns `cleanup_incomplete` after about 1 s: "Owned Rizin debugger inferior detach was not verified within 1000 ms". One Rizin process and one `cat` process stay running under the server's user. REA's own commands appear on the selected TTY: `olj` and `!echo __REA_CLEANUP_COMPLETE_…__`. ### Reproduction 1. Over MCP, call `start_rizin_debug_session` on `/usr/bin/cat`. 2. Call `close_rizin_debug_session`. 3. Observe the result above. Reproduced 3 of 3 with `cat`, and on `sha256sum`. ### Expected behavior Rizin exits and the target is detached. The target may keep running, as the tool description says. ### Impact and scope Each close on a stdin-reading target leaves one Rizin process and the target running, and the target reads REA's commands. The CLI path hangs (below). Other platforms and Rizin versions were not tested. ### REA version `rea-agents` 6.8.0 ### Runtime and platform Node 24.22.2; Debian 13 x86-64; Rizin 0.9.1 ### Target and artifact context ELF x86-64 system binaries: `cat`, `sha256sum`, `yes`, `true` ### Interface MCP; also CLI ### Earliest failure stage Cleanup, cancellation, or lifecycle ### Relevant output or evidence | Target, unmodified | Close | | :-- | :-- | | `cat`, 3 of 3 | `cleanup_incomplete`, 1.0 s | | `sha256sum` | `cleanup_incomplete`, 1.0 s | | `yes`, ignores stdin, still running after close | clean, 0.03 s | | `true`, exits by itself | clean, 0.03 s | **CLI path:** `rea debug-with-rizin /usr/bin/cat dr --inferior-tty <pty> --format json` prints its result, then hangs. Still hung at 30 s with Rizin and `cat` running; with `-R stdin=<tty>` it exits 0 in 1.87 s. `/usr/bin/true` exits 0. ### Analysis or suspected cause `start_rizin_debug_session` passes `-R stdout=<tty> -R stderr=<tty>` and sends commands on stdin, without `-R stdin=`. In `/proc`, the target's fd 0 is the same socket as Rizin's fd 0. Detach resumes the target, which reads the next commands, so Rizin never answers. **Tested fix:** a wrapper that adds `-R stdin=<tty>` and execs Rizin, set through `REA_RIZIN_COMMAND`. `cat` 3 of 3 and `sha256sum` close clean in 0.03 s and stay running, with nothing on the TTY. A passthrough wrapper still fails. `/dev/null` was not tested. **Source only:** `src/rizin/RizinDebugSessionManager.ts` on `main` at `8250bf232` passes the same arguments. We did not run `main`. ### Additional context **Also seen on:** 6.7.0 carrying a local cleanup patch, so this may not be new in 6.8.0. We have not compared unpatched 6.7.0. **Related, not duplicates:** #5516 changes Rizin cancellation and exit drain; #8024 covers a session stopped by its frame limit; #7143 covers `cleanup_incomplete` across user namespaces; closed #5277 reports a first-close failure on a short-lived target, where `true` closed clean here. None was tested here.
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#7501
No description provided.