Repository navigation
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Huffman decoding readers now pass 15 byte-read errors through ChangesDeflate truncation handling
Priority: ⚪ Not assessed Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Truncated DEFLATE input is intended to report an incomplete stream. No concrete merge-blocking risk remains; this is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for the review and merge! Glad the truncated-stream case is covered. |
Replace the generated huffmanBytesBuffer with a hand-written decoder that views the remaining compressed input as a slice via Bytes() and keeps a 64-bit bit buffer refilled with one 8-byte load per symbol, instead of pulling bytes one at a time into the 32-bit buffer. One refill holds at least 56 bits, covering a worst-case lit/len code, length extra, distance code and distance extra without touching the input again; the byte-at-a-time refill loops only run inside the last 8 bytes of input. Over-read bytes are rewound and consumed input is drained with Next on every exit, preserving the decompressor's b/nb/roffset invariants for the shared state machine. Decode throughput improves 14-17% on twain/digits at default level, and 9-14% on gzipped OTLP telemetry payloads, where it compounds with the reader-reuse gains to 40-55% over stdlib-based decode paths. The generator now skips emitting the bytes.Buffer template body but still emits its dispatch case, so removing the hand-written file breaks compilation rather than silently falling back. Truncated input inside length/distance extra bits reports io.ErrUnexpectedEOF, matching the generated decoders since klauspost#1229. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JuXmUKPiPDVnaoRpDd853j
Fixes #1228.
The generated DEFLATE Huffman readers propagated a raw
io.EOFwhile reading length or distance extra bits. When the input stopped at those positions,ReadAllandio.Copyinterpreted it as a successful end of stream, even though the final block had not been reached. Convert EOF toio.ErrUnexpectedEOFat those three read sites in the generator and regenerate all five reader variants.A regression covers every byte cut of the reported stream, five reader types, both
ReadAllandio.Copy, and the complete-stream control. Before the fix, cuts 14, 16, 17, and 18 returned nil; afterward every truncated cut reportsio.ErrUnexpectedEOFand the full stream still decodes.Local validation:
go test ./flate -count=1,go test -race ./flate -count=1,go test ./gzip ./zlib -count=1,go vet ./flate ./gzip ./zlib, andgit diff --checkpass. The full repository test suite and upstream CI have not run yet.Summary by CodeRabbit