Repository navigation
fix: reset read offset when Read drains the current block - #76
Conversation
Read set z.current to nil after draining a block but left z.roff at the offset of earlier partial reads. A following WriteTo then sliced the nil z.current with that stale offset and panicked (slice bounds out of range [N:0]). This is hit by archive/tar reading a stream that ends exactly at the end-of-archive marker, followed by io.Copy. Adds regression tests for both cases. Fixes klauspost#74
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughReader.Read now resets its read offset after releasing the current block. Two regression tests check that copying from the reader after consuming its data completes without error. ChangesReader offset reset
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This fixes a panic when io.Copy or WriteTo follows a Read that drains the current block. The change is a single localized offset reset with regression tests, so merge risk is minimal. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
…set, and format
* feat: resolve issue #24 - Parallel zlib writer implementation Signed-off-by: AdamMagued <[email protected]> * fix(zlib): address concurrency and error handling review findings in reader and writer * zlib: merge master, port #76, wait for output listener on Reset, and format --------- Signed-off-by: AdamMagued <[email protected]>
Fixes #74
Reader.Read set z.current = nil after draining a block without resetting z.roff, so a following WriteTo (io.Copy) sliced the nil z.current with a stale offset and panicked. Resetting the offset together with z.current fixes it.
Tests: two regression tests that panic without the change (one through archive/tar, which ends exactly at the end-of-archive marker). Checked with gofmt, go vet, go test -cpu=1,2,4 . and go test -cpu=2 -race -short .
Summary by CodeRabbit