Repository navigation
Conversation
The typed zip rewrite (0b59d98) returned z_stream total_in/total_out, which accumulate across calls, but haxe.zip Compress/Uncompress.execute callers treat read/write as this call's progress. Uncompress.run threw OutsideBounds once output exceeded its 64K buffer, and chunked callers re-read input. Add a multi-buffer round-trip test that exceeds the default buffer.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Since the typed zip rewrite (#1277),
ZLibCompress::executeandZLibUncompress::executereturnz_stream::total_in/total_out. Those totals accumulate across calls, buthaxe.zip.Compress.execute/Uncompress.executecallers, includingUncompress.run, treatread/writeas the progress of the current call.As a result,
haxe.zip.Uncompress.run(bytes)throwsOutsideBoundsonce the decompressed output exceeds its 64K buffer. On the second iterationwritereports the running total, soaddBytes(tmp, 0, r.write)reads pasttmp. Chunkedexecuteloops also re-read input, becausepos += r.readadvances by the total.Reproduction
This works on haxelib hxcpp 4.3.2 and fails on releases from v4.3.106 onward. Single-call use (output under 64K) is unaffected, which is why the existing
testCompresspasses.Change
executenow returns the per-call counts,src.length - avail_inanddst.length - avail_out, in both files. I also addedtestCompressMultipleBufferstotest/std, which round-trips 300 KB throughUncompress.runand through a chunkedexecuteloop with a 4K output buffer.Testing
On Linux x86_64 (GCC 13.3, Haxe 4.3.7), I ran the same assertions as a standalone program:
Uncompress.runover 64K, chunked decode, chunked compress into 512-byte buffers, and a 1 MiB real-world asset. Before the change they fail withOutsideBounds; after it they pass. I couldn't run the fulltest/stdsuite locally because it doesn't compile against utest 1.13.2 (Assert.exceptionat Test.hx:452, unrelated to this change).