New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io: ReadAll doesn't respect io.ErrShortBuffer #48432
Comments
Also, you shouldn’t need |
The problem with partial reads with small buffer is that they aren't actually possible with the current https://play.golang.org/p/9e5bcYIb_1n For a first read, There's just no way for a downstream |
The As @ericlagergren says, an implementation of I'm going to close this issue because I don't think there is anything to change here. Please comment if you disagree. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?(not relevant)
What did you do?
I create an
io.Reader
that sometimes returnsio.ErrShortBuffer
. Then, I try to slurp data from it viaio.ReadAll()
.What did you expect to see?
io.ReadAll()
manages its buffer properly and retriesr.Read()
with a bigger buffer.What did you see instead?
io.ReadAll()
returnsio.ErrShortBuffer
on a firstErrShortBuffer
encounter.Notes
I believe that it should handle the
ErrShortBuffer
gracefully by default.There's a memory management problem: faulty Reader might spam
ErrShortBuffer
and the buffer would grow exponentially; however,ReadAll
doesn't care about that by default since the source itself is unbounded and data can outgrow available memory pretty easily.Edit: oh, I've noticed that many reader implementations incl. bufio, bytes etc don't support ErrShortBuffer as well. Is there any canonical way to signal upstream that a buffer must be grown?
The text was updated successfully, but these errors were encountered: