You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like the idea of unblocking data from the zlib backreference buffer by knowing that we won't use it again in a decompression call. That said the inflater.finish logic seems to become obsolete (for treating the symptom) once image-rs/fdeflate#59 is utilized, right? It's not that different from #644 in that regard.
I've thought about the buf_independent test some more, and I think there's still and additional case this PR doesn't handle. The problem is when the final bytes of the zlib stream contains an error after all of the pixel data. Decoding byte-by-byte will complete the next_frame call successfully, while the all-at-once decoder will notice the error in the same operation as reading the final row of pixels.
Though honestly the best fix might be to just adjust buf_independent to call both next_frame and finish consecutively, and not distinguish which one returns the error. (We'd still need to make sure that finish surfaced any errors that were skipped, but that would be less complicated/invasive than other alternatives)
Though honestly the best fix might be to just adjust buf_independent to call both next_frame and finish consecutively, and not distinguish which one returns the error. (We'd still need to make sure that finish surfaced any errors that were skipped, but that would be less complicated/invasive than other alternatives)
+1
FWIW there are still cases where zlib errors are ignored - e.g. IIUC Reader::next_frame_info will call:
Reader::finish_decoding which calls ReadDecoder::finish_decoding_image_data which passes a None buffer to StreamDecoder
Reader::read_until_image_data which calls ReadDecoder::read_until_image_data which passes a None buffer to StreamDecoder.
So errors may or may not be reported depending on which client APIs are used (e.g. next_frame decodes the image and detects errors VS next_frame_info which skips to the next frame and ignores zlib errors in the current frame). And in theory the buffering patterns (e.g. when exactly UnexpectedEof is reported) may influence how client APIs are used. But I still think this is fine (and shouldn't matter for buf_independent.rs) and we should merge this PR. Thanks for putting it together!
@fintelia / @197g - are there any remaining concerns or action items for this PR? Merging this PR will unblock/simplify the changes in another PR at #664
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt to fix #605 by tracking precisely how many bytes there are left in a frame so that we don't decompress more zlib data than we need.
Doesn't fully fix theFuzzing seems to pass now.buf_independentfuzz test, but gets us closer. Will investigate more when I have a chance...