Skip to content

fix(runtime): bound all crash-handler formatting (review finding from #86)#87

Merged
CoreyRDean merged 1 commit into
developfrom
fix/setranslator-buffer-bounds
Jun 9, 2026
Merged

fix(runtime): bound all crash-handler formatting (review finding from #86)#87
CoreyRDean merged 1 commit into
developfrom
fix/setranslator-buffer-bounds

Conversation

@CoreyRDean

Copy link
Copy Markdown
Collaborator

Quality-gate review of #86 caught a real defect in the new diagnostics: the seTranslator regs line formats 110 chars + NUL into char info[96] — a guaranteed 15-byte stack OOB write on every exception reaching the diagnostics path. It only appeared to work because the handler never returns (no /GS check fires) and the local layout happened to be benign; the write could still silently clobber panicStr/cx/mbi — the very state being reported.

Fixes, all within the crash handler:

  • info[96]info[160]; every format in the handler now goes through snprintf(…,sizeof…) so the crash path can never corrupt its own frame again.
  • describeAddress/symbolName formatting bounded the same way (pathologically long exe basename could overflow buf[160]).
  • The anonymous-image dump now VirtualQuerys the dump range itself and clamps to the committed region (the allocation base's region can differ from the faulting IP's; a nested fault inside the handler would truncate the whole panic).

Full test.bat green (includes the divzero crash-diagnostic contract, which exercises the handler end-to-end).

🤖 Generated with Claude Code

…86)

The seTranslator regs line formatted 110 chars + NUL into char info[96]
-- a guaranteed 15-byte stack OOB write on every exception that reached
the diagnostics path. It went unnoticed only because the handler never
returns (no /GS check) and MSVC's local layout happened to be benign;
the writes could still silently clobber the very state the diagnostics
report. Quality-gate review caught it via byte-counting.

- info[96] -> info[160] and every format in the handler switched to
  snprintf(sizeof) -- the crash path can no longer corrupt its own frame.
- describeAddress/symbolName formatting bounded the same way (a
  pathologically long exe basename could overflow buf[160]).
- The anonymous-image dump now VirtualQuery's the dump range itself
  (the allocation base's region can differ from the faulting IP's
  region; a nested fault inside the handler would truncate the panic).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CoreyRDean CoreyRDean requested a review from a team as a code owner June 9, 2026 22:52
@CoreyRDean CoreyRDean merged commit bdbfd9f into develop Jun 9, 2026
4 checks passed
@CoreyRDean CoreyRDean deleted the fix/setranslator-buffer-bounds branch June 9, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant