Skip to content

set err to nil after ReadFull returns io.EOF#245

Merged
pierrec merged 1 commit into
pierrec:v4from
serprex:fix-read-eof-regression
May 31, 2026
Merged

set err to nil after ReadFull returns io.EOF#245
pierrec merged 1 commit into
pierrec:v4from
serprex:fix-read-eof-regression

Conversation

@serprex

@serprex serprex commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

When source size is multiple of block size, final io.ReadFull returns (0, io.EOF) err only cleared by w.write when rn > 0

This broke io.Copy which uses dst.(io.ReaderFrom) shortcut, propagating io.EOF to caller

Regression from #240

When source size is multiple of block size, final io.ReadFull returns (0, io.EOF)
`err` only cleared by `w.write` when `rn > 0`

This broke io.Copy which uses dst.(io.ReaderFrom) shortcut,
propagating io.EOF to caller
@serprex

serprex commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

@lkinley-rythmos

@serprex

serprex commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

Alternatively not using implicit return variables here could be used. Personally I configure linting to prevent use of that feature

Comment thread writer.go
@@ -222,6 +222,7 @@ func (w *Writer) ReadFrom(r io.Reader) (n int64, err error) {
switch err {
case nil:
case io.EOF, io.ErrUnexpectedEOF: // read may be partial

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo UnexpectedEOF should not be ignored, but that's a larger change of behavior predating recent regression

serprex added a commit to wal-g/wal-g that referenced this pull request Apr 30, 2026
bumped in #2233 this regressed gp/cloudberry due to pierrec/lz4#245
@serprex serprex mentioned this pull request May 30, 2026
Closed
@pierrec
pierrec merged commit 17a7cd8 into pierrec:v4 May 31, 2026
9 checks passed
@serprex serprex mentioned this pull request Jun 1, 2026
debebantur pushed a commit to wal-g/wal-g that referenced this pull request Jun 1, 2026
4.1.27 contains both
pierrec/lz4#240
& pierrec/lz4#245

which are relevant when we're often compressing files with sizes that are a power of 2
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.

2 participants