Skip to content

fix(gdb): keep sessions usable after an oversized stream record - #8029

Merged
morluto merged 3 commits into
morluto:mainfrom
rohitg00:fix/gdb-oversized-stream-record
Nov 4, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
rohitg00:fix/gdb-oversized-stream-record

Conversation

@rohitg00

@rohitg00 rohitg00 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A single GDB console, target or log record over the 16 MiB MI line limit failed the whole session protocol. Close then could not verify detach, so GDB and the inferior stayed owned with no way out. MI stream records carry only output, and MI c-strings escape newlines, so a raw LF always ends the record. #receive now drops the rest of an oversized stream record, marks the command output_truncated, and keeps the session usable. Oversized result and async records still stop the session, as before. Close and detach behavior are unchanged.

Fixes #8023.

Validation

  • npm run test:focused -- tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/cli/gdbStartupCleanupCli.test.ts: 206 passed. The new stream-record test fails on main; the oversized result-record test passes on both.
  • npm run check:fast, npm run docs:check and git diff --check: pass.
  • Not covered: real GDB on Linux. The tests use fake MI peers that answer only the modeled requests.

Author readiness

Human owner: @rohitg00

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

A single MI console, target or log record over the 16 MiB line limit
failed the whole session protocol, so close could not re-synchronize
and GDB plus its inferior stayed owned with no recovery path.

MI stream records carry only output and c-strings escape newlines, so
a raw LF always ends the record. #receive now drops the remainder of
an oversized stream record, marks pending command output and retained
records truncated, and keeps parsing later lines; oversized result
and async records still fail closed as before.

Fixes morluto#8023.
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR keeps GDB sessions usable after an oversized console, target, or log record. It drops that record through its terminating LF and marks output as truncated.

  • GDB sessions stay usable after oversized stream output.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[MI record exceeds 16 MiB] --> B{Starts with console, target, or log prefix?}
  B -->|Yes| C[Clear buffered record and mark output truncated]
  C --> D[Skip through terminating LF]
  D --> E[Read following MI records normally]
  B -->|No| F[Fail the session protocol]
Loading

Reviews (1) · Last reviewed commit: "test(gdb): drop superseded oversized-rec..." · Reviewed by Greptile

@rohitg00
rohitg00 marked this pull request as ready for review October 29, 2026 13:43
@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-29T13:43:41.589303Z
We couldn’t complete this review. Comment @codex review to try again.
7690596 Draft marked ready
ℹ️ 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.

@Rinkia

Rinkia commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

I tested this PR at 769059639 against main at 4b961e371. I used the #8023 repro: GNU gdb 15.1 in a Linux x64 container, the utf8 probe with int big[4000000], and print elements and print repeats both set to 0. I ran the sequence over MCP with /dev/pts/0 as the inferior TTY.

main:

  • print big and every later call return cleanup_incomplete, including close_gdb_session.
  • gdb --nx --interpreter=mi3 and the stopped /p/utf8 stay behind.

This PR:

  • print big returns ^done with output_truncated: true. The oversized record is dropped.
  • The session stays ready. The later commands all work:
    • print big[3999999] returns $2 = 3999999.
    • The shell command with invalid UTF-8 reports its replacement-character limitation.
    • echo works.
    • print bad returns the escaped bytes.
    • kill works.
  • close_gdb_session returns target_state: "none_observed", and no processes are left.

One small point. The truncated print big result carries the existing limitation "Retained MI records reached the 16777216 byte or 16384 record cap … Output completeness is unknown." It is accurate, but it doesn't say that a single console record over the line limit was dropped. A caller can't tell that from a retained-record cap, so naming the dropped record would help.

I also tested #8091, which takes the other approach: it closes the session and terminates GDB. The two look complementary. This PR keeps the session for oversized stream records. #8091's forced stop would still cover protocol failures that this PR leaves fail-closed, such as an oversized result record, which I didn't trigger.

@morluto
morluto merged commit f042aaa into morluto:main Nov 4, 2026
43 of 45 checks passed
@morluto morluto added bug Something isn't working provider: gdb Analysis provider / engine: gdb 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: gdb Analysis provider / engine: gdb

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A GDB console command whose output is one MI line over 16 MiB ends the session with no way to detach, kill or close it

3 participants