Skip to content

fix: detect a panic header split across reads - #35

Open
SashaMIT wants to merge 1 commit into
bugsnag:masterfrom
SashaMIT:fix/split-panic-header
Open

SashaMIT wants to merge 1 commit into
bugsnag:masterfrom
SashaMIT:fix/split-panic-header

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 11, 2026 •

Copy link
Copy Markdown

Goal

trackPanic searched each stderr read on its own. A header that started in one read and finished in the next was forwarded as ordinary output, and the handler never ran. The skipped TestPanicWrap_panicBoundary is that case: the child writes pan, then ic: oh crap.

Changeset

Changed

trackPanic keeps a tail shorter than fatal error: and joins it to the next read before treating the text as ordinary output. On end of input that tail is written out. A read error ends the scan.

Tests

TestTrackPanic_splitHeader writes before pan and then ic: split through a pipe. On the old reader the panic text was empty and the boundary helper exited 2. After the join the handler sees panic: split, the prefix before is forwarded, and the boundary helper prints wrapped: 14.

go test -count=1 . passed.

Discussion

The held tail is one byte shorter than the longest header, so a split panic: or fatal error: is still visible. Ordinary output waits for the next read, or for the stream to end.

Review

  • Reviewed the test cases added for completeness and possible points for discussion
  • A changelog entry was added for the goal of this pull request
  • Check the scope of the changeset - is everything in the diff required for the pull request?
  • This pull request is ready for:
    • Final review

A header that started in one stderr read and finished in the next was
forwarded as ordinary output, so the handler never ran.
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