### What version of Go are you using (`go version`)? <pre> $ go version go version go1.18.3 linux/amd64 </pre> ### Does this issue reproduce with the latest release? Yes. ### What did you do? See example: https://go.dev/play/p/Bn8H6p4QUf6 ### What did you expect to see? I expect that bufio package react on underlying reader errors and stop the reading. ### What did you see instead? I see that bufio skips an error multiple times, and the example code causes OOM error becuase reader is rewinded every time: here are cases when an error is not tracked: https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=148;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673 https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=496;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673 https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=566;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673 https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=571;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673 the error, returned by autoRewind is just ignored and set to nil: https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/bufio/bufio.go;l=156;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673 https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/bufio/bufio.go;l=124;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673 I know that it's something that I have to expect with autoRewind, but this behavior caused an unpleasant surprise. see also: * https://github.com/golang/go/issues/53854 * https://github.com/golang/go/issues/53855
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes.
What did you do?
See example: https://go.dev/play/p/Bn8H6p4QUf6
What did you expect to see?
I expect that bufio package react on underlying reader errors and stop the reading.
What did you see instead?
I see that bufio skips an error multiple times, and the example code causes OOM error becuase reader is rewinded every time:
here are cases when an error is not tracked:
https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=148;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673
https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=496;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673
https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=566;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673
https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/net/textproto/reader.go;l=571;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673
the error, returned by autoRewind is just ignored and set to nil:
https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/bufio/bufio.go;l=156;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673
https://cs.opensource.google/go/go/+/refs/tags/go1.18.4:src/bufio/bufio.go;l=124;drc=27794c4d4a18c61d8c158d253421d72b5a6a8673
I know that it's something that I have to expect with autoRewind, but this behavior caused an unpleasant surprise.
see also: