Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct edge values of window_bits #60

Merged
merged 7 commits into from
Jan 6, 2025
Merged

Conversation

f3fora
Copy link
Contributor

@f3fora f3fora commented Mar 25, 2022

@mkitti
Copy link
Member

mkitti commented Jan 24, 2023

I'm not clear if this agrees with https://www.zlib.net/manual.html

@ViralBShah ViralBShah marked this pull request as draft January 9, 2024 05:08
src/compression.jl Outdated Show resolved Hide resolved
src/compression.jl Outdated Show resolved Hide resolved
src/decompression.jl Outdated Show resolved Hide resolved
src/decompression.jl Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.66%. Comparing base (3192d0f) to head (e6fdac9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #60   +/-   ##
=======================================
  Coverage   91.66%   91.66%           
=======================================
  Files           4        4           
  Lines         156      156           
=======================================
  Hits          143      143           
  Misses         13       13           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nhz2
Copy link
Member

nhz2 commented Jan 6, 2025

The zlib manual section on deflateInit2 is not straight forward about windowbits=8

The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead.

For the current implementation of deflate(), a windowBits value of 8 (a window size of 256 bytes) is not supported. As a result, a request for 8 will result in 9 (a 512-byte window). In that case, providing 8 to inflateInit2() will result in an error when the zlib header with 9 is checked against the initialization of inflate(). The remedy is to not use 8 with deflateInit2() with this initialization, or at least in that case use 9 with inflateInit2().

I think windowbits=8 was originally intended to work, but there is a bug in zlib so now it isn't allowed.

Ref: madler/zlib#737 madler/zlib#171

@nhz2 nhz2 marked this pull request as ready for review January 6, 2025 18:12
@nhz2
Copy link
Member

nhz2 commented Jan 6, 2025

I'm going to merge this now to be able to move forward on some other issues, but @mkitti and @f3fora please open an issue if there are any problems with this change, or if you need support for other advanced zlib configuration options.

@nhz2 nhz2 merged commit 3f91138 into JuliaIO:master Jan 6, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants