mirror of
https://github.com/google/brotli.git
synced 2026-09-22 06:35:52 +00:00
go: Flush() does not completely process all data following a large Write() #415
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hochhaus on GitHub (Mar 11, 2022).
Thanks for providing the brotli library and corresponding cgo bindings.
I am seeing the Flush() calls not completely process all data following a call to a large Write(). Modifying your unit test
TestEncoderFlushto use an input size of32766instead of1000demonstrates the behavior.results in
Is it expected that large Writes() are supported? Is the unit test somehow using the API incorrectly to ensure all data is both written and flushed?
@eustas commented on GitHub (Mar 11, 2022):
Hello. Thanks for the report. Will investigate on Monday.
@hochhaus commented on GitHub (Mar 11, 2022):
Thanks @eustas.
@eustas commented on GitHub (Mar 14, 2022):
Reproducible. Digging in.
@eustas commented on GitHub (Mar 14, 2022):
Hoi. Well, it is not an issue.
io.Readerinterface allows partial reads, if decoder decides it would be blocked to read further.This is the case. If you add the second read in the test (or read in the loop, until all compressed input is consumed), the test will succeed.
TestEncoderFlushcase checks different aspects of the codec behaviour, that is why payload length is chosen to be 1000.From debugging output I've seen that all data passed to encoder is processed.
There are two checks that ensure correct behaviour:
io.Copydoes not return error -> all input taken from source is consumed by encoderoutis not empty afterFlush-> encoder was forced to process all consumed inputOverall: try to
Readin the loop, until all compressed input is consumed. If it does not help, feel free to reopen this isssue.@hochhaus commented on GitHub (Mar 15, 2022):
Thanks @eustas. As you say, looping the
Read()fixes what I reported here.It appears the real bug I'm chasing might actually be in firefox instead. I'll work on filing that upstream.
@hochhaus commented on GitHub (Mar 15, 2022):
In case a future reader hits a similar issue as I did, I found that brotli compressed chunks great than 128k are not eagerly processed by FF. I filed an upstream issue.