[PR #3580] fix(debugger): shield inferior identity verification on proc stat ENOENT #5835

Open
opened 2026-10-31 01:09:47 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3580
Author: @qorvr
Created: 10/14/2026
Status: 🔄 Open

Base: main ← Head: fix/inferior-identity-proc-stat


📝 Commits (2)

  • d765d5f fix(debugger): shield inferior identity verification on proc stat ENOENT
  • 4654152 fix(debugger): reject missing inferior PID during detach and add regression tests

📊 Changes

4 files changed (+396 additions, -29 deletions)

View changed files

📝 src/gdb/GdbSessionManager.ts (+69 -16)
📝 src/rizin/RizinDebugSessionManager.ts (+46 -13)
📝 tests/boundary/providers/GdbSessionManagerCoverage.test.ts (+251 -0)
📝 tests/boundary/providers/RizinInferiorTty.test.ts (+30 -0)

📄 Description

Summary

Prevents unhandled filesystem ENOENT exceptions during GDB and Rizin inferior process identity verification and detach checks, ensuring failures cleanly escalate to domain errors.

Problem and expected behavior

  • In src/gdb/GdbSessionManager.ts, reading /proc/${pid}/stat or descriptor paths (/proc/${pid}/fd/1, /proc/${pid}/fd/2) throws a raw Node.js ENOENT error if the inferior process disappears or terminates before or during verification. Expected behavior is to cleanly throw the domain error "GDB could not establish the live inferior identity." or "The GDB inferior identity changed during descriptor readback.".
  • In src/rizin/RizinDebugSessionManager.ts, if the inferior process exits during detach, readProcStartTime throws raw ENOENT instead of allowing assertRizinProcessStartTimeStable to report "The inferior PID disappeared or was reused during detach verification.".

Change and scope

  • Wrap /proc/${pid}/stat and descriptor reads in verifyGdbInferiorOutputSink and readProcStartTime in try / catch handling ENOENT specifically to escalate cleanly to expected domain errors.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: GdbSessionManager, RizinDebugSessionManager.
  • Contribution scope fit and linked maintainer decision: not applicable (existing boundaries and failure path hardening).
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: Linux /proc identity verification.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): retained process ownership and clean detach error reporting.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): 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: tests/boundary/providers/GdbSessionManagerCoverage.test.ts, tests/boundary/providers/RizinInferiorTty.test.ts.
  • Base reproduction or other evidence: When an inferior terminates during live verification, readFile('/proc/${pid}/stat') raises unhandled ENOENT instead of escalating to the expected session error.
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: none.

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

  • oxfmt --check . — all matched files passed formatting check.
  • npm run typecheck — 0 errors.
  • npm run lint — 0 errors.
  • npx vitest run tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/providers/RizinInferiorTty.test.ts — 155/156 passed (1 skipped).
  • npx vitest run tests/boundary/providers/ghidra/ghidraClient.test.ts — 35/36 passed (1 skipped).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux /proc inferior tracking.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: Prevents unhandled filesystem errors during process inspection from leaking internal paths or crashing the session manager.

Author readiness

Human owner: @qorvr

  • 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/3580 **Author:** [@qorvr](https://github.com/qorvr) **Created:** 10/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/inferior-identity-proc-stat` --- ### 📝 Commits (2) - [`d765d5f`](https://github.com/morluto/rea/commit/d765d5f77c8eac962e7083b3529887aa55525f59) fix(debugger): shield inferior identity verification on proc stat ENOENT - [`4654152`](https://github.com/morluto/rea/commit/46541520acc2435d8a790f2877acdf3529f2c9fe) fix(debugger): reject missing inferior PID during detach and add regression tests ### 📊 Changes **4 files changed** (+396 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `src/gdb/GdbSessionManager.ts` (+69 -16) 📝 `src/rizin/RizinDebugSessionManager.ts` (+46 -13) 📝 `tests/boundary/providers/GdbSessionManagerCoverage.test.ts` (+251 -0) 📝 `tests/boundary/providers/RizinInferiorTty.test.ts` (+30 -0) </details> ### 📄 Description ## Summary Prevents unhandled filesystem `ENOENT` exceptions during GDB and Rizin inferior process identity verification and detach checks, ensuring failures cleanly escalate to domain errors. ## Problem and expected behavior - In `src/gdb/GdbSessionManager.ts`, reading `/proc/${pid}/stat` or descriptor paths (`/proc/${pid}/fd/1`, `/proc/${pid}/fd/2`) throws a raw Node.js `ENOENT` error if the inferior process disappears or terminates before or during verification. Expected behavior is to cleanly throw the domain error `"GDB could not establish the live inferior identity."` or `"The GDB inferior identity changed during descriptor readback."`. - In `src/rizin/RizinDebugSessionManager.ts`, if the inferior process exits during detach, `readProcStartTime` throws raw `ENOENT` instead of allowing `assertRizinProcessStartTimeStable` to report `"The inferior PID disappeared or was reused during detach verification."`. ## Change and scope - Wrap `/proc/${pid}/stat` and descriptor reads in `verifyGdbInferiorOutputSink` and `readProcStartTime` in `try / catch` handling `ENOENT` specifically to escalate cleanly to expected domain errors. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact - Semantic owner and earliest changed stage: `GdbSessionManager`, `RizinDebugSessionManager`. - Contribution scope fit and linked maintainer decision: not applicable (existing boundaries and failure path hardening). - CLI and MCP/tool-catalog contract: none. - Provider, bridge, target-format, or platform compatibility: Linux `/proc` identity verification. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details (if applicable): retained process ownership and clean detach error reporting. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): none. Expected effects: - [ ] 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: `tests/boundary/providers/GdbSessionManagerCoverage.test.ts`, `tests/boundary/providers/RizinInferiorTty.test.ts`. - Base reproduction or other evidence: When an inferior terminates during live verification, `readFile('/proc/${pid}/stat')` raises unhandled `ENOENT` instead of escalating to the expected session error. - User-visible CLI/MCP output (if applicable): none. - Remaining proof gaps: none. 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 - `oxfmt --check .` — all matched files passed formatting check. - `npm run typecheck` — 0 errors. - `npm run lint` — 0 errors. - `npx vitest run tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/providers/RizinInferiorTty.test.ts` — 155/156 passed (1 skipped). - `npx vitest run tests/boundary/providers/ghidra/ghidraClient.test.ts` — 35/36 passed (1 skipped). ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: Linux `/proc` inferior tracking. - Package or release metadata impact: none. - Security, privacy, process, or containment review: Prevents unhandled filesystem errors during process inspection from leaking internal paths or crashing the session manager. ## Author readiness Human owner: @qorvr - [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>
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#5835
No description provided.