]> git.ipfire.org Git - thirdparty/zstd.git/commit
[versions-test] Work around bug in dictionary builder for older versions
authorNick Terrell <terrelln@fb.com>
Thu, 19 Jan 2023 20:21:31 +0000 (12:21 -0800)
committerNick Terrell <nickrterrell@gmail.com>
Fri, 20 Jan 2023 22:05:36 +0000 (14:05 -0800)
commit667eb6d4fd1677aa0de109673868ff47b0532e45
tree4f6d1bd2bc86bf92cc8d352a37501fff0073c6d9
parent666944fbe6bb5e6d84a343ad4df525af79720165
[versions-test] Work around bug in dictionary builder for older versions

Older versions of zstandard have a bug in the dictionary builder, that
can cause dictionary building to fail. The process still exits 0, but
the dictionary is not created.

For reference, the bug is that it creates a dictionary that starts with
the zstd dictionary magic, in the process of writing the dictionary header,
but the header isn't fully written yet, and zstd fails compressions in
this case, because the dictionary is malformated. We fixed this later on
by trying to load the dictionary as a zstd dictionary, but if that fails
we fallback to content only (by default).

The fix is to:
1. Make the dictionary determinsitic by sorting the input files.
   Previously the bug would only sometimes occur, when the input files
   were in a particular order.
2. If dictionary creation fails, fallback to the `head` dictionary.
tests/test-zstd-versions.py