[PR #5801] fix(gdb): correlate newline-free shell completion with MI prompt #7071

Open
opened 2026-11-01 21:45:09 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5801
Author: @jhuang-tw
Created: 10/21/2026
Status: 🔄 Open

Base: main ← Head: fix/gdb-shell-joined-mi-completion


📝 Commits (4)

  • cf52cf1 fix(gdb): correlate newline-free shell MI completion after prompt
  • 94a0c8a test(gdb): verify joined shell completion, prompt and spoof controls
  • 2768d67 test(gdb): cover newline-free shell and strict MI completion controls
  • 4a11e49 fix(gdb): retain exact pending token for joined terminal

📊 Changes

2 files changed (+100 additions, -6 deletions)

View changed files

📝 src/gdb/GdbSessionManager.ts (+31 -6)
📝 tests/boundary/providers/GdbSessionManagers.test.ts (+69 -0)

📄 Description

Problem

Refs #5761. Real GDB MI accepts -interpreter-exec console "shell printf abc", but if the shell doesn't print LF, its stdout joins GDB's MI completion as a single received line, e.g. abc4^done. The normal line-anchored MI matcher in GdbSessionManager.#receive correctly refuses the joined line, but without additional framing the command hangs until the 120 s timeout, turning completed work into cleanup_incomplete.

The reporter independently reproduced this with real GDB 13.1, including a newline-terminated passing control.

Candidate narrowly scoped change

  • Only for a pending shell console command, retain an exact matching <token>^done suffix after the unrestricted shell bytes.
  • Require a subsequent standalone GDB prompt before accepting the recovered completion. Other MI commands still require normal line-anchored result records.
  • Preserve the full original joined raw MI line in Evidence, and return the canonical terminal token separately in mi; keep the existing timeout/partial-Evidence path when the second boundary is absent.
  • Preserve GDB process ownership, command/output limits, cancellation, and cleanup behavior.

Added source-owned boundary regression

The fake GDB fixture exercises:

  1. abc<token>^done followed by a GDB prompt (positive).
  2. a suffix-shaped shell line followed by a later genuine line-anchored MI record (negative control).
  3. ordinary non-shell console commands still requiring a proper line-anchored MI record.

Important limitations / before ready

Draft for CI-driven verification. This GitHub-only workspace cannot run the pinned local Node/Vitest toolchain because the authorized Windows Vyrnu/Zenu execution services are unavailable. Tests and formatting have not been claimed to pass locally; please treat CI as the initial executable verification gate.

A subsequent prompt improves correlation but does not prove authenticity against malicious unrestricted shell output on a shared pipe; a shell could forge both a token-shaped suffix and a prompt. This narrow candidate does not address cryptographic framing. This caveat warrants review before merging.

Three-file? No: exactly two files, one GDB session manager and one focused boundary-test file. No dependency or configuration changes. AI-assisted contribution, maintained by jhuang-tw.


🔄 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/5801 **Author:** [@jhuang-tw](https://github.com/jhuang-tw) **Created:** 10/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/gdb-shell-joined-mi-completion` --- ### 📝 Commits (4) - [`cf52cf1`](https://github.com/morluto/rea/commit/cf52cf1712dfc0ec0c7da532b4a395cb5eea9a80) fix(gdb): correlate newline-free shell MI completion after prompt - [`94a0c8a`](https://github.com/morluto/rea/commit/94a0c8af832cabcf30969061d32e57bb2f5a3a13) test(gdb): verify joined shell completion, prompt and spoof controls - [`2768d67`](https://github.com/morluto/rea/commit/2768d67a02d3c0e9f2a1edc16a56b761665269b2) test(gdb): cover newline-free shell and strict MI completion controls - [`4a11e49`](https://github.com/morluto/rea/commit/4a11e4924cc781911352abb98a926df60290f055) fix(gdb): retain exact pending token for joined terminal ### 📊 Changes **2 files changed** (+100 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/gdb/GdbSessionManager.ts` (+31 -6) 📝 `tests/boundary/providers/GdbSessionManagers.test.ts` (+69 -0) </details> ### 📄 Description ## Problem Refs #5761. Real GDB MI accepts `-interpreter-exec console "shell printf abc"`, but if the shell doesn't print LF, its stdout joins GDB's MI completion as a single received line, e.g. `abc4^done`. The normal line-anchored MI matcher in `GdbSessionManager.#receive` correctly refuses the joined line, but without additional framing the command hangs until the 120 s timeout, turning completed work into `cleanup_incomplete`. The reporter independently reproduced this with real GDB 13.1, including a newline-terminated passing control. ## Candidate narrowly scoped change - Only for a pending **shell** console command, retain an exact matching `<token>^done` suffix after the unrestricted shell bytes. - Require a subsequent standalone GDB prompt before accepting the recovered completion. Other MI commands still require normal line-anchored result records. - Preserve the full original joined raw MI line in Evidence, and return the canonical terminal token separately in `mi`; keep the existing timeout/partial-Evidence path when the second boundary is absent. - Preserve GDB process ownership, command/output limits, cancellation, and cleanup behavior. ## Added source-owned boundary regression The fake GDB fixture exercises: 1. `abc<token>^done` followed by a GDB prompt (positive). 2. a suffix-shaped shell line followed by a later genuine line-anchored MI record (negative control). 3. ordinary non-shell console commands still requiring a proper line-anchored MI record. ## Important limitations / before ready **Draft for CI-driven verification.** This GitHub-only workspace cannot run the pinned local Node/Vitest toolchain because the authorized Windows Vyrnu/Zenu execution services are unavailable. Tests and formatting have **not** been claimed to pass locally; please treat CI as the initial executable verification gate. A subsequent prompt improves correlation but **does not prove authenticity** against malicious unrestricted shell output on a shared pipe; a shell could forge both a token-shaped suffix and a prompt. This narrow candidate does not address cryptographic framing. This caveat warrants review before merging. Three-file? No: exactly two files, one GDB session manager and one focused boundary-test file. No dependency or configuration changes. AI-assisted contribution, maintained by `jhuang-tw`. --- <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#7071
No description provided.