Repository navigation
Conversation
terrelln
force-pushed
the
2026-12-02-huffman-max-11-bits
branch
from
December 3, 2026 17:27
ccf0f97 to
b035490
Compare
Contributor
Author
|
Ok, looks like the v0.7 dictionary builder emitted dictionaries in the v1.0 dictionary format which used a Huffman table log of 12. So if we started rejecting this entirely, we'd break these dictionaries, if any such dictionaries even exist. |
RFC 8878, section 4.2.1 limits the maximum code length to 11 bits, but HUF_TABLELOG_MAX was 12, so the decoder accepted Huffman tables with 12-bit codes, and so did the compressor when loading a dictionary. Set HUF_TABLELOG_MAX to 11, which libzstd's compressor and dictionary builder already use, so one limit is enforced for frames and dictionaries, for decompression and compression. Decoding tables keep their capacity of HUF_TABLELOG_ABSOLUTEMAX (12), so the decoders are otherwise unchanged. No release from v1.0.0 to v1.6.0 produces a table deeper than 11 bits. Two test inputs that were not made by libzstd had 12-bit tables, and now use 11 bits: test_optimalParserDictEntropy() and the http-dict-missing-symbols dictionary. Add tests for 11- and 12-bit trees, and document the change in doc/decompressor_permissive.md.
terrelln
force-pushed
the
2026-12-02-huffman-max-11-bits
branch
from
December 4, 2026 21:49
b035490 to
a6cfe80
Compare
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.
RFC 8878, section 4.2.1 limits the maximum code length to 11 bits, but
HUF_TABLELOG_MAXwas 12, so the decoder accepted Huffman tables with 12-bit codes, and so did the compressor when loading a dictionary.Set
HUF_TABLELOG_MAXto 11, which libzstd's compressor and dictionary builder already use, so one limit is enforced for frames and dictionaries, for decompression and compression. Decoding tables keep their capacity ofHUF_TABLELOG_ABSOLUTEMAX(12), so the decoders are otherwise unchanged.No release from v1.0.0 to v1.6.0 produces a table deeper than 11 bits. Two test inputs that were not made by libzstd had 12-bit tables, and now use 11 bits: test_optimalParserDictEntropy() and the http-dict-missing-symbols dictionary.
Add tests for 11- and 12-bit trees, and document the change in doc/decompressor_permissive.md.