Repository navigation
Conversation
FIO_adjustParamsForPatchFromMode() computes the window log of the source
with FIO_highbit64(maxSrcFileSize), which asserts v != 0. When the file
to compress is empty, maxSrcFileSize is 0, so
zstd --patch-from=ref empty
aborts on the assertion. The CLI is built with assert() enabled by
default, so this crashes the regular `zstd` binary.
An empty source only needs the smallest window, so use
ZSTD_WINDOWLOG_MIN in that case. This is the window log the clamp below
already selected for any small source.
Add a cli-test that compresses and decompresses an empty file with
--patch-from.
This branch has not been deployed
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.
What and why
zstd --patch-from=REF emptyaborts on an assert when the file to compress is empty:FIO_adjustParamsForPatchFromMode()computes the window log withFIO_highbit64(maxSrcFileSize), which needs a non-zero value, andmaxSrcFileSizeis 0 here. The CLI keepsassert()on in its default build, so this crashes the regular binary (exit 134).An empty source only needs the smallest window, so this uses
ZSTD_WINDOWLOG_MINwhen the size is 0. That is the value the clamp right below already picks for any tiny source, so non-empty inputs don't change.The new cli-test
compression/patch-from.shround-trips an empty file with--patch-from. It fails with exit code 134 without the fix.Checklist
A gain in one configuration is not a general gain: see the Performance section of CONTRIBUTING.md.
Tools used
An AI coding agent (Claude Code) found the problem and wrote the change and the test.