Repository navigation
zlib upgrade broke known vectors #50138
Description
Activity
- addedzlibIssues and PRs related to the zlib module and its compression dependencies.Issues and PRs related to the zlib module and its compression dependencies.dependenciesPRs that add, update, or configure Node.js dependencies.PRs that add, update, or configure Node.js dependencies.
on Oct 11, 2023 cc: @Adenilson
Why do you think 660f902 is involved in the issue?
It was/is my limited understanding that the zlib output is deterministic.
Whilst I can confirm the different versions can inflate/deflate each other this change in output is unexpected, to me at least.
I can mark the jose test as not reproducible to have it not check equal outputs but the cookbook of these vectors does not mention the zlib deflate output to be variable.
Reacted by Luigi PincaWhilst I can confirm the different versions can inflate/deflate each other this change in output is unexpected, to me at least.
I also tested this. Let's wait a little to see if we can get some feedback from @Adenilson.
Sounds good, i'll also wait on marking the test as non-deterministic in the jose test suite then.
It was/is my limited understanding that the zlib output is deterministic.
It's not. The only requirement is that it properly round-trips. I'll go ahead and close this.
Reacted by Filip Skokan- addedinvalidIssues and PRs that are invalid.Issues and PRs that are invalid.
on Oct 11, 2023 Fair enough. Thank you @bnoordhuis
I'm left yearning more details though if you would find the time.
It was/is my limited understanding that the zlib output is deterministic.
It's not. The only requirement is that it properly round-trips. I'll go ahead and close this.
That is correct (i.e. the requirement is that it round-trips and its compatible with other implementations).
I will repost here a comment related to the subject that I made during the review of the first landed patch:
"
Changes in the algorithmic implementation in zlib may change the compressed bitstream, but the decompressed content is still the same (otherwise the data would be corrupted).Unfortunately, there are tests that compare compressed content in different ways.
It seems to be a common behavior by client code to assume some sort of 'binary stability' when it comes to gzip compressed streams.
There are no such guarantees even between releases of zlib and I've spent quite some time suggesting that people should compare decompressed content while writing tests.
"Basically if there are changes in the way that we perform matches (i.e. longest_match) or in the way we keep track of those in a hash table (i.e. by changing the hashing function), the compressed output will be different but still a valid GZIP stream that must be compatible with other implementations.
As an experiment, try to compress a given file using canonical zlib (it uses a Rabin-Karp hash) and compare what other forks (e.g. Chromium zlib now uses ANZAC++, before we were using CRC-32) will produce and it should be different.
But they must be compatible with each other (e.g. compress with one library, decompress with another and vice-versa) and the decompressed result must match with the original input.
I hope that helps to clarify the subject and feel free to contact me if you run in any issues.
:-)Reacted by Luigi PincaReacted by Filip SkokanFor context, the test that triggered the revert of the original patch turned out to be flakey:
https://bugs.chromium.org/p/chromium/issues/detail?id=1487363#c20Reacted by Luigi Pinca- added 4 commits that reference this issue
on Oct 22, 2023 - added a commit that references this issue
on Dec 1, 2023

See nodejs/citgm#1011
I suggest to revert the following commits and add unit tests for more known vectors to prevent breaking updates in the future.
cc @alfonsograziano @lpinca @aduh95