]> git.ipfire.org Git - thirdparty/zlib-ng.git/log
thirdparty/zlib-ng.git
3 years agoUsed fixed width uint8_t for crc32 and adler32 function declarations.
Nathan Moinvaziri [Sun, 5 Jun 2022 20:59:44 +0000 (13:59 -0700)] 
Used fixed width uint8_t for crc32 and adler32 function declarations.

3 years agoUse uint64_t instead of size_t for len in adler32 to be consistent with crc32.
Nathan Moinvaziri [Mon, 6 Jun 2022 04:28:49 +0000 (21:28 -0700)] 
Use uint64_t instead of size_t for len in adler32 to be consistent with crc32.

3 years agoFix MSVC possible loss of data warning in crc32_pclmulqdq by converting len types...
Nathan Moinvaziri [Sun, 5 Jun 2022 23:54:32 +0000 (16:54 -0700)] 
Fix MSVC possible loss of data warning in crc32_pclmulqdq by converting len types to use uint64_t.

arch\x86\crc32_fold_pclmulqdq.c(604,43): warning C4244: 'function':
  conversion from 'uint64_t' to 'size_t', possible loss of data

3 years agoPrint gtest_zlib test results using color.
Nathan Moinvaziri [Tue, 21 Jun 2022 03:27:00 +0000 (20:27 -0700)] 
Print gtest_zlib test results using color.

3 years agoIn compatibility mode, always define z_crc_t as uint32_t for backwards compatibility.
Mika Lindqvist [Fri, 17 Jun 2022 10:06:56 +0000 (13:06 +0300)] 
In compatibility mode, always define z_crc_t as uint32_t for backwards compatibility.

3 years agoFix typo
Tobias Stoeckmann [Sat, 18 Jun 2022 19:00:10 +0000 (21:00 +0200)] 
Fix typo

Typo found with codespell.

3 years agoAdd public compile definition for zlib-ng API so that other projects that use CMake...
Nathan Moinvaziri [Sun, 12 Jun 2022 16:01:15 +0000 (09:01 -0700)] 
Add public compile definition for zlib-ng API so that other projects that use CMake and link against the zlib project can easily determine whether or not to include "zlib-ng.h" or "zlib.h".

3 years agoHandle invalid windowBits in init functions
Tobias Stoeckmann [Mon, 13 Jun 2022 16:43:16 +0000 (18:43 +0200)] 
Handle invalid windowBits in init functions

Negative windowBits arguments are eventually turned positive in
deflateInit2_ and inflateInit2_ (more precisely in inflateReset2).
Such values are used to indicate that raw deflate/inflate should
be performed.

If a user supplies INT32_MIN for windowBits, the code will perform
-INT32_MIN which does not fit into int32_t. In fact, this is
undefined behavior in C and should be avoided.

Clearly this is a user error, but given the careful validation of
input arguments a few lines later in deflateInit2_ I think this
might be of interest.

Proof of Concept:

- Compile zlib-ng with gcc -ftrapv or -fsanitize=undefined
- Compile and run this program:

```
 #include <limits.h>
 #include <stdio.h>
 #include <zlib-ng.h>

 int main(void) {
  zng_stream de_stream = { 0 }, in_stream = { 0 };
  int result;

  result = zng_deflateInit2(&de_stream, 0, Z_DEFLATED, INT32_MIN,
      MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  printf("zng_deflateInit2: %d\n", result);

  result = zng_inflateInit2(&in_stream, INT32_MIN);
  printf("zng_inflateInit2: %d\n", result);

  return 0;
 }
```

3 years agoExtend GZIP conditional
Tobias Stoeckmann [Mon, 13 Jun 2022 16:46:00 +0000 (18:46 +0200)] 
Extend GZIP conditional

If gzip support has been disabled during compilation then also
consider gzip relevant states as invalid in deflateStateCheck.

Also the gzip state definitions can be removed.

This change leads to failure in test/example, and I am not sure
what the GZIP conditional is trying to achieve. All gzip related
functions are still defined in zlib.h

Alternative approach is to remove the GZIP define.

3 years agoFixed conversion warnings for wsize in slide_hash_c.
Nathan Moinvaziri [Tue, 7 Jun 2022 15:54:26 +0000 (08:54 -0700)] 
Fixed conversion warnings for wsize in slide_hash_c.

  slide_hash.c(50,44): warning C4244: 'function': conversion from 'unsigned int' to 'uint16_t', possible loss of data
  slide_hash.c(51,40): warning C4244: 'function': conversion from 'unsigned int' to 'uint16_t', possible loss of data

3 years agoFixed inflate size conversion warning in chunkcopy_safe.
Nathan Moinvaziri [Mon, 6 Jun 2022 23:22:26 +0000 (16:22 -0700)] 
Fixed inflate size conversion warning in chunkcopy_safe.

  inflate_p.h(142,27): warning C4244: 'function': conversion from 'uint64_t' to 'size_t', possible loss of data

3 years agozlib 1.2.12
Nathan Moinvaziri [Tue, 7 Jun 2022 21:21:48 +0000 (14:21 -0700)] 
zlib 1.2.12

3 years agoRemove unused chunkcopy_safe function prototypes.
Nathan Moinvaziri [Mon, 6 Jun 2022 23:20:17 +0000 (16:20 -0700)] 
Remove unused chunkcopy_safe function prototypes.

3 years agoFixed signed warnings in GZ unit tests.
Nathan Moinvaziri [Mon, 6 Jun 2022 23:18:19 +0000 (16:18 -0700)] 
Fixed signed warnings in GZ unit tests.

  test_gzio.cc(44): warning C4389: '!=': signed/unsigned mismatch
  test_gzio.cc(72): warning C4389: '!=': signed/unsigned mismatch

3 years agoAdded Intel's Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instructio...
Nathan Moinvaziri [Sun, 5 Jun 2022 20:38:51 +0000 (13:38 -0700)] 
Added Intel's Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction paper to docs folder.

3 years agoUpload abi files when pkgcheck failure occurs.
Nathan Moinvaziri [Sat, 4 Jun 2022 16:20:46 +0000 (09:20 -0700)] 
Upload abi files when pkgcheck failure occurs.

3 years agoabicheck.sh: update reference versions.
Dan Kegel [Sat, 4 Jun 2022 16:44:10 +0000 (09:44 -0700)] 
abicheck.sh: update reference versions.

Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
3 years agoMove crc32 fold functions into templates. Don't store xmm_crc_part between runs becau...
Nathan Moinvaziri [Fri, 15 Apr 2022 02:49:32 +0000 (19:49 -0700)] 
Move crc32 fold functions into templates. Don't store xmm_crc_part between runs because it is automatically folded into the checksum in partial_fold.

Co-authored-by: Adam Stylinski <kungfujesus06@gmail.com>
3 years agoRemove zng_gzgetc_ function from zlib-ng native API.
Hans Kristian Rosbach [Fri, 11 Feb 2022 12:49:28 +0000 (13:49 +0100)] 
Remove zng_gzgetc_ function from zlib-ng native API.
It exists in zlib for backwards compatibility, but has never been
documented/advertised for use in zlib-ngs native API.

3 years agoSimplify version and struct size checking, and ensure we do it the same way everywhere.
Hans Kristian Rosbach [Fri, 11 Feb 2022 11:08:43 +0000 (12:08 +0100)] 
Simplify version and struct size checking, and ensure we do it the same way everywhere.

3 years agoSimplify zlib-ng native API by removing version and struct size checks.
Hans Kristian Rosbach [Fri, 11 Feb 2022 10:11:04 +0000 (11:11 +0100)] 
Simplify zlib-ng native API by removing version and struct size checks.
This should be backwards compatible with applications compiled for 2.0.x.

3 years ago[ARM] We need to include NEON headers when testing for -mfpu=neon.
Mika Lindqvist [Tue, 31 May 2022 12:58:17 +0000 (15:58 +0300)] 
[ARM] We need to include NEON headers when testing for -mfpu=neon.
* If -mfpu is already specified in C_FLAGS, it can disable NEON support.

3 years agoCMakeLists.txt: fix version in zlib.pc when building statically
Fabrice Fontaine [Fri, 27 May 2022 21:25:21 +0000 (23:25 +0200)] 
CMakeLists.txt: fix version in zlib.pc when building statically

When building statically (i.e. with BUILD_SHARED_LIBS=OFF),
ZLIB_FULL_VERSION is not set resulting in an empty version in zlib.pc
and the following build failure with transmission:

checking for ZLIB... configure: error: Package requirements (zlib >= 1.2.3) were not met:

Package dependency requirement 'zlib >= 1.2.3' could not be satisfied.
Package 'zlib' has version '', required version is '>= 1.2.3'

Fixes:
 - http://autobuild.buildroot.org/results/b3b882482f517726e5c780ba4c37818bd379df82

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3 years agoAllow external gtest
Vladislav Shchapov [Thu, 26 May 2022 18:39:04 +0000 (23:39 +0500)] 
Allow external gtest

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
3 years agoCorrect incorrect inputs provided to the CRC functions.
Mark Adler [Tue, 10 May 2022 15:11:32 +0000 (08:11 -0700)] 
Correct incorrect inputs provided to the CRC functions.
The previous releases of zlib were not sensitive to incorrect CRC
inputs with bits set above the low 32. This commit restores that
behavior, so that applications with such bugs will continue to
operate as before.

Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
3 years agoCorrect comment for x2nmodp.
Mark Adler [Tue, 10 May 2022 15:04:47 +0000 (08:04 -0700)] 
Correct comment for x2nmodp.

3 years agoDefine W = 8 on powerpc64 for braided crc32 generation.
Nathan Moinvaziri [Tue, 10 May 2022 06:42:00 +0000 (23:42 -0700)] 
Define W = 8 on powerpc64 for braided crc32 generation.

3 years agoSpeed up software CRC-32 computation by a factor of 1.5 to 3.
Nathan Moinvaziri [Tue, 24 May 2022 18:44:20 +0000 (11:44 -0700)] 
Speed up software CRC-32 computation by a factor of 1.5 to 3.
Use the interleaved method of Kadatch and Jenkins in order to make
use of pipelined instructions through multiple ALUs in a single
core. This also speeds up and simplifies the combination of CRCs,
and updates the functions to pre-calculate and use an operator for
CRC combination.

Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
3 years agoAdding avx512_vnni inline + copy elision
Adam Stylinski [Fri, 8 Apr 2022 17:24:21 +0000 (13:24 -0400)] 
Adding avx512_vnni inline + copy elision

Interesting revelation while benchmarking all of this is that our
chunkmemset_avx seems to be slower in a lot of use cases than
chunkmemset_sse.  That will be an interesting function to attempt to
optimize.

Right now though, we're basically beating google for all PNG decode and
encode benchmarks.  There are some variations of flags that can
basically have us trading blows, but we're about as much as 14% faster
than chromium's zlib patches.

While we're here, add a more direct benchmark of the folded copy method
versus the explicit copy + checksum.

3 years agoAdded inlined AVX512 adler checksum + copy
Adam Stylinski [Fri, 8 Apr 2022 02:57:09 +0000 (22:57 -0400)] 
Added inlined AVX512 adler checksum + copy

While we're here, also simplfy the "fold" signature, as reducing the
number of rebases and horizontal sums did not prove to be meaningfully
faster (slower in many circumstances).

3 years agoAdd AVX2 inline copy + adler implementation
Adam Stylinski [Wed, 6 Apr 2022 19:38:20 +0000 (15:38 -0400)] 
Add AVX2 inline copy + adler implementation

This was pretty much across the board wins for performance, but the wins
are very data dependent and it sort of depends on what copy runs look
like.  On our less than realistic data in benchmark_zlib_apps, the
decode test saw some of the bigger gains, ranging anywhere from 6 to 11%
when compiled with AVX2 on a Cascade Lake CPU (and with only AVX2
enabled).  The decode on realistic imagery enjoyed smaller gains,
somewhere between 2 and 4%.

Interestingly, there was one outlier on encode, at level 5.  The best
theory for this is that the copy runs for that particular compression
level were such that glibc's ERMS aware memmove implementation managed
to marginally outpace the copy during the checksum with the move rep str
sequence thanks to clever microcoding on Intel's part. It's hard to say
for sure but the most standout difference between the two perf profiles
was more time spent in memmove (which is expected, as it's calling
memcpy instead of copying the bytes during the checksum).

There's the distinct possibility that the AVX2 checksums could be
marginally improved by one level of unrolling (like what's done in the
SSE3 implementation).  The AVX512 implementations are certainly getting
gains from this but it's not appropriate to append this optimization in
this series of commits.

3 years agoAdding an SSE42 optimized copy + adler checksum implementation
Adam Stylinski [Sun, 3 Apr 2022 16:18:12 +0000 (12:18 -0400)] 
Adding an SSE42 optimized copy + adler checksum implementation

We are protecting its usage around a lot of preprocessor macros as the
other methods are not yet implemented and calling this version bypasses
the faster adler implementations implicitly.

When more versions are written for faster vectorizations, the functable
entries will be populated and preprocessor macros removed. This round,
the copy + checksum is not employing as many tricks as one would hope
with a "folded" checksum routine.  The reason for this is the
particularly tricky case of dealing with unaligned buffers.  The
implementations which don't have CPUs in the mix that have a huge
penalty for unaligned loads will have a much faster implementation.

Fancier methods that minimized rebasing, while having the potential to
be faster, ended up being slower because the compiler structured the
code in a way that ended up either spilling to the stack or trampolining
out of a loop and back in it instead of just jumping over the first load
and store.

Revisiting this for AVX512, where more registers are abundant and more
advanced loads exist, may be prudent.

3 years agoCreate adler32_fold_c* functions
Adam Stylinski [Fri, 1 Apr 2022 23:02:05 +0000 (19:02 -0400)] 
Create adler32_fold_c* functions

These are very simple wrappers that do nothing clever but serve as a
shim interface for implementing versions which do cleverly track the
number of scalar sums performed so that we can minimize rebasing and
also have an efficient copy elision.

This serves as the baseline as each vectorization gets its own commit.
That way the PR will be bisectable.

3 years agoImproved chunkset substantially where it's heavily used
Adam Stylinski [Sun, 10 Apr 2022 17:01:22 +0000 (13:01 -0400)] 
Improved chunkset substantially where it's heavily used

For most realistic use cases, this doesn't make a ton of difference.
However, for things which are highly compressible and enjoy very large
run length encodes in the window, this is a huge win.

We leverage a permutation table to swizzle the contents of the memory
chunk into a vector register and then splat that over memory with a fast
copy loop.

In essence, where this helps, it helps a lot.  Where it doesn't, it does
no measurable damage to the runtime.

This commit also simplifies a chunkcopy_safe call for determining a
distance.  Using labs is enough to give the same behavior as before,
with the added benefit that no predication is required _and_, most
importantly, static analysis by GCC's string fortification can't throw a
fit because it conveys better to the compiler that the input into
builtin_memcpy will always be in range.

3 years agoMake directory for output files.
Vladislav Shchapov [Thu, 12 May 2022 13:36:42 +0000 (18:36 +0500)] 
Make directory for output files.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
3 years agoFixed incorrect case for __clang__ preprocessor macro in zbuild.h.
Nathan Moinvaziri [Tue, 10 May 2022 06:32:32 +0000 (23:32 -0700)] 
Fixed incorrect case for __clang__ preprocessor macro in zbuild.h.

3 years agoFixed issue #1264: Use fallback for _mm256_zextsi128_si256 on Xcode < 9.3
Sean McBride [Mon, 9 May 2022 20:02:41 +0000 (16:02 -0400)] 
Fixed issue #1264: Use fallback for _mm256_zextsi128_si256 on Xcode < 9.3

3 years agoRemove extra CMake messages from ARM toolchains.
Nathan Moinvaziri [Mon, 9 May 2022 16:53:43 +0000 (09:53 -0700)] 
Remove extra CMake messages from ARM toolchains.

3 years agoImplement power9 version of compare256.
Matheus Castanho [Sun, 17 Apr 2022 00:12:53 +0000 (17:12 -0700)] 
Implement power9 version of compare256.

Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
3 years agoThe names CMAKE_INTERPROCEDURAL_OPTIMIZATION_* must be uppercase.
Vladislav Shchapov [Thu, 5 May 2022 11:51:17 +0000 (16:51 +0500)] 
The names CMAKE_INTERPROCEDURAL_OPTIMIZATION_* must be uppercase.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
3 years agoImplement neon version of compare256.
Nathan Moinvaziri [Mon, 18 Apr 2022 01:47:07 +0000 (18:47 -0700)] 
Implement neon version of compare256.

Co-authored-by: Adam Stylinski <kungfujesus06@gmail.com>
3 years agoFixed warning about strict prototypes for cpu_check_features.
Nathan Moinvaziri [Tue, 3 May 2022 18:12:46 +0000 (11:12 -0700)] 
Fixed warning about strict prototypes for cpu_check_features.

3 years agoRemove unused chunkmemset_1 code.
Nathan Moinvaziri [Tue, 3 May 2022 22:40:44 +0000 (15:40 -0700)] 
Remove unused chunkmemset_1 code.

3 years agoDisable redirection to 64-bit function variants when Z_SOLO is defined
Mika Lindqvist [Tue, 3 May 2022 00:47:52 +0000 (03:47 +0300)] 
Disable redirection to 64-bit function variants when Z_SOLO is defined

See #1262.

3 years agoImprove deflateBound unit test to test a range of small buffer lengths with various...
Nathan Moinvaziri [Sun, 10 Apr 2022 05:20:39 +0000 (22:20 -0700)] 
Improve deflateBound unit test to test a range of small buffer lengths with various deflateBound initialization values.

Co-authored-by: Mika T. Lindqvist <postmaster@raasu.org>
3 years agoAdded compressBound tests for small buffers.
Nathan Moinvaziri [Sun, 10 Apr 2022 05:19:56 +0000 (22:19 -0700)] 
Added compressBound tests for small buffers.

Co-authored-by: Mika T. Lindqvist <postmaster@raasu.org>
3 years agoFixed MSVC warning about unknown option for AVX512 flag.
Nathan Moinvaziri [Wed, 27 Apr 2022 16:26:31 +0000 (09:26 -0700)] 
Fixed MSVC warning about unknown option for AVX512 flag.

cl : command line warning D9002: ignoring unknown option '/ARCH:AVX512'

3 years agoAdd test for stream adler after inflateSetDictionary
Josh Triplett [Wed, 27 Apr 2022 00:21:13 +0000 (17:21 -0700)] 
Add test for stream adler after inflateSetDictionary

This test passes prior to commit
8550a90de4dcb8589a7d48fe308c4c45bba5a466 ("Leverage inline CRC + copy")
and fails after that commit.

3 years agoFixed regression introduced by inlining CRC + copy
Adam Stylinski [Wed, 27 Apr 2022 01:53:30 +0000 (21:53 -0400)] 
Fixed regression introduced by inlining CRC + copy

Pretty much every time updatewindow has been called, implicitly a
checksum was performed unless on s/390 or state->wrap & 4 == 0. The
inflateSetDictionary function instead separately calls this checksum
before invoking update window and checks the checksum to see if it
matches the initial checksum (a property that happens from parsing the
DICTID section of the headers).

Instead, we can make updatewindow have a "copy" parameter, which is the
state->wrap value that is being checked anyway.  We instead move the 3rd
bit check to be checked by the caller rather than the callee.

3 years agoIBM Z DFLTCC: Split deflate and inflate states
Ilya Leoshkevich [Wed, 13 Apr 2022 11:46:24 +0000 (13:46 +0200)] 
IBM Z DFLTCC: Split deflate and inflate states

Currently deflate and inflate both use a common state struct. There are
several variables in this struct that we don't need for inflate, and
more may be coming in the future. Therefore split them in two separate
structs. This in turn requires splitting ZALLOC_STATE and ZCOPY_STATE
macros.

3 years agomacOs M1 build fix on arm cpu checks.
David CARLIER [Fri, 18 Mar 2022 21:01:00 +0000 (21:01 +0000)] 
macOs M1 build fix on arm cpu checks.

3 years agoRemove trailing whitespace in several source code files
Dženan Zukić [Mon, 25 Apr 2022 18:42:11 +0000 (14:42 -0400)] 
Remove trailing whitespace in several source code files

3 years agoFixed forcing CMAKE_BUILD_TYPE to Release on multi config generators such as Xcode...
Nathan Moinvaziri [Fri, 22 Apr 2022 21:58:24 +0000 (14:58 -0700)] 
Fixed forcing CMAKE_BUILD_TYPE to Release on multi config generators such as Xcode or MSVC.

Co-authored-by: Sergey Markelov <sergio-nsk@users.noreply.github.com>
3 years agoRemove CVE testing from configure script.
Nathan Moinvaziri [Sat, 9 Apr 2022 20:43:53 +0000 (13:43 -0700)] 
Remove CVE testing from configure script.

3 years agoUse PREFIX() for some of the Z_INTERNAL symbols
Ilya Leoshkevich [Tue, 12 Apr 2022 13:16:20 +0000 (15:16 +0200)] 
Use PREFIX() for some of the Z_INTERNAL symbols

https://github.com/powturbo/TurboBench links zlib and zlib-ng into the
same binary, causing non-static symbol conflicts. Fix by using PREFIX()
for flush_pending(), bi_reverse(), inflate_ensure_window() and all of
the IBM Z symbols.

Note: do not use an explicit zng_, since one of the long-term goals is
to be able to link two versions of zlib-ng into the same binary for
benchmarking [1].

[1] https://github.com/zlib-ng/zlib-ng/pull/1248#issuecomment-1096648932

3 years agoDon't try to build tests or benchmarks if cmake is too old for them.
Mika Lindqvist [Wed, 13 Apr 2022 01:24:12 +0000 (04:24 +0300)] 
Don't try to build tests or benchmarks if cmake is too old for them.

3 years agoCheck that sys/auxv.h exists at configure time and add preprocessor define for it.
Mika Lindqvist [Tue, 12 Apr 2022 22:22:29 +0000 (01:22 +0300)] 
Check that sys/auxv.h exists at configure time and add preprocessor define for it.
* Protect including sys/auxv.h in all relevant files with the new preprocessor define
* Test for both existence of both sys/auxv.h and getauxval() with both cmake and configure

3 years agoFixed failed tools tests when source directory is read-only.
Nathan Moinvaziri [Sat, 9 Apr 2022 04:43:54 +0000 (21:43 -0700)] 
Fixed failed tools tests when source directory is read-only.

3 years agoAdd test for issue #1235.
Mika Lindqvist [Wed, 6 Apr 2022 20:49:24 +0000 (23:49 +0300)] 
Add test for issue #1235.
* Test both compressBound() and deflateBound() as those share same code fragment.

3 years agoAdd one extra byte to return value of compressBound and deflateBound for small length...
Mika Lindqvist [Tue, 5 Apr 2022 21:04:45 +0000 (00:04 +0300)] 
Add one extra byte to return value of compressBound and deflateBound for small lengths due to shift returning 0.
* Treat 0 byte input as 1 byte input when calculating compressBound and deflateBound

3 years agoDisable LTO in CMake
Vladislav Shchapov [Mon, 4 Apr 2022 08:37:12 +0000 (13:37 +0500)] 
Disable LTO in CMake

3 years agoUse _msan_unposion to unposion end of window for when it needs to read the past ...
Nathan Moinvaziri [Mon, 11 Apr 2022 02:35:12 +0000 (19:35 -0700)] 
Use _msan_unposion to unposion end of window for when it needs to read the past < chunksize bytes in the window. See #1245.

Co-authored-by: Adam Stylinski <kungfujesus06@gmail.com>
3 years agoRename memory alignment functions because they handle custom allocator which is the...
Nathan Moinvaziri [Mon, 11 Apr 2022 02:20:23 +0000 (19:20 -0700)] 
Rename memory alignment functions because they handle custom allocator which is the first parameter so having calloc and cfree (c = custom) is confusing in the name.

3 years agoFixed off-by-one error when benchmarking compare256 resulting in heap-buffer-overflow.
Nathan Moinvaziri [Sat, 9 Apr 2022 14:22:01 +0000 (07:22 -0700)] 
Fixed off-by-one error when benchmarking compare256 resulting in heap-buffer-overflow.

3 years agoMimic minigzip behavior and only unlink files if not using -c copy out argument.
Nathan Moinvaziri [Fri, 8 Apr 2022 03:39:21 +0000 (20:39 -0700)] 
Mimic minigzip behavior and only unlink files if not using -c copy out argument.

3 years agoFix the custom PNG image based benchmark
Adam Stylinski [Wed, 6 Apr 2022 22:15:57 +0000 (18:15 -0400)] 
Fix the custom PNG image based benchmark

The height parameter was using a fixed macro, written at a time when the
test imagery was fully synthetic.  Because of this, images smaller than
than our in-memory generated imagery will artificially throw a CRC
error.

3 years agoRemove sanitizer support from configure since it is better supported in cmake. Anybod...
Nathan Moinvaziri [Sat, 2 Apr 2022 21:49:28 +0000 (14:49 -0700)] 
Remove sanitizer support from configure since it is better supported in cmake. Anybody who still needs it can use cmake or manually set CFLAGS and LDFLAGS.

3 years agoabicheck.sh: don't export CHOST if it wasn't already exported.
Dan Kegel [Sun, 3 Apr 2022 18:27:39 +0000 (11:27 -0700)] 
abicheck.sh: don't export CHOST if it wasn't already exported.

This fixes https://github.com/zlib-ng/zlib-ng/issues/1219,
a regression when running abicheck.sh with default compiler.

3 years agoFixed missing crc32_combine exports for zlib 1.2.12.
Nathan Moinvaziri [Sun, 3 Apr 2022 00:31:45 +0000 (17:31 -0700)] 
Fixed missing crc32_combine exports for zlib 1.2.12.

3 years agoabicheck.sh: zlib-ng is a bash script, not a sh script, don't hardcode shell when...
Dan Kegel [Fri, 1 Apr 2022 19:42:28 +0000 (19:42 +0000)] 
abicheck.sh: zlib-ng is a bash script, not a sh script, don't hardcode shell when running configure

3 years agoFixed building tests when -DWITH_GZFILEOP=OFF
Nathan Moinvaziri [Sat, 2 Apr 2022 22:41:21 +0000 (15:41 -0700)] 
Fixed building tests when -DWITH_GZFILEOP=OFF

3 years agoMove fuzzer cmake into fuzz directory.
Nathan Moinvaziri [Sat, 2 Apr 2022 22:31:22 +0000 (15:31 -0700)] 
Move fuzzer cmake into fuzz directory.

3 years agoUse latest stable version of google test instead of unstable main branch.
Nathan Moinvaziri [Sat, 2 Apr 2022 22:13:16 +0000 (15:13 -0700)] 
Use latest stable version of google test instead of unstable main branch.

3 years agoabicheck.sh: implement --refresh-if option as documented.
Dan Kegel [Fri, 1 Apr 2022 19:38:36 +0000 (19:38 +0000)] 
abicheck.sh: implement --refresh-if option as documented.

Also change exit status to nonzero if there is no abifile and --refresh or --refresh-if were not specified.

3 years agoGrammar fixes
Shlomi Fish [Sat, 2 Apr 2022 10:16:47 +0000 (13:16 +0300)] 
Grammar fixes

3 years agoRemove support for building fuzzers from configure.
Nathan Moinvaziri [Thu, 31 Mar 2022 16:50:52 +0000 (09:50 -0700)] 
Remove support for building fuzzers from configure.

3 years agoTest CVE-2018-25032 against the default level and levels 1 and 2.
Nathan Moinvaziri [Thu, 31 Mar 2022 17:04:49 +0000 (10:04 -0700)] 
Test CVE-2018-25032 against the default level and levels 1 and 2.

3 years agoAdded unit test against CVE-2018-25032 with default strategy.
Nathan Moinvaziri [Mon, 28 Mar 2022 14:53:55 +0000 (07:53 -0700)] 
Added unit test against CVE-2018-25032 with default strategy.

Co-authored-by: Eric Biggers <ebiggers@kernel.org>
3 years agoAdded unit test against CVE-2018-25032.
Nathan Moinvaziri [Sun, 27 Mar 2022 00:49:49 +0000 (17:49 -0700)] 
Added unit test against CVE-2018-25032.
Sample input from https://www.openwall.com/lists/oss-security/2022/03/26/1.

Co-authored-by: Tavis Ormandy <taviso@users.noreply.github.com>
3 years agoAdded missing -F argument for Z_FIXED strategy in minideflate.
Nathan Moinvaziri [Sun, 27 Mar 2022 00:26:16 +0000 (17:26 -0700)] 
Added missing -F argument for Z_FIXED strategy in minideflate.

3 years agoUse size_t types for len arithmetic, matching signature
Adam Stylinski [Sun, 27 Mar 2022 23:20:08 +0000 (19:20 -0400)] 
Use size_t types for len arithmetic, matching signature

This suppresses a warning and keeps everything safely the same type.
While it's unlikely that the input for any of this will exceed the size
of an unsigned 32 bit integer, this approach is cleaner than casting and
should not result in a performance degradation.

3 years agoUse standalone fuzzing runner only when fuzzing engine is not found.
Nathan Moinvaziri [Mon, 28 Mar 2022 23:52:02 +0000 (16:52 -0700)] 
Use standalone fuzzing runner only when fuzzing engine is not found.

3 years agoAllow SSE2 and AVX2 functions with -DWITH_UNALIGNED=OFF. Even though they use unalign...
Nathan Moinvaziri [Sun, 27 Mar 2022 20:18:03 +0000 (13:18 -0700)] 
Allow SSE2 and AVX2 functions with -DWITH_UNALIGNED=OFF. Even though they use unaligned loads, they don't result in undefined behavior.

3 years agoLeverage inline CRC + copy
Adam Stylinski [Sat, 12 Mar 2022 21:09:02 +0000 (16:09 -0500)] 
Leverage inline CRC + copy

This brings back a bit of the performance that may have been sacrificed
by reverting the reorganized inflate window. Doing a copy at the same
time as a CRC is basically free.

3 years agoFixed clang signed/unsigned warning in chunkcopy_safe.
Nathan Moinvaziri [Sun, 27 Mar 2022 20:44:58 +0000 (13:44 -0700)] 
Fixed clang signed/unsigned warning in chunkcopy_safe.

inflate_p.h:159:18: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'size_t' (aka 'unsigned long') [-Wsign-compare]
        tocopy = MIN(non_olap_size, len);
                 ^   ~~~~~~~~~~~~~  ~~~
zbuild.h:74:24: note: expanded from macro 'MIN'
#define MIN(a, b) ((a) > (b) ? (b) : (a))
                    ~  ^  ~

3 years agoUse specific gcovr version 5.0 due to parser errors with 5.1.
Nathan Moinvaziri [Sun, 27 Mar 2022 16:14:45 +0000 (09:14 -0700)] 
Use specific gcovr version 5.0 due to parser errors with 5.1.
https://github.com/gcovr/gcovr/issues/583

3 years agoRemove unistd.h include from gzguts.h which is already included from zconf.h via...
Nathan Moinvaziri [Sat, 26 Mar 2022 17:37:29 +0000 (10:37 -0700)] 
Remove unistd.h include from gzguts.h which is already included from zconf.h via zlib.h.

3 years agoUse HAVE instead of HAS for variable name for consistency.
Nathan Moinvaziri [Sat, 26 Mar 2022 15:47:01 +0000 (08:47 -0700)] 
Use HAVE instead of HAS for variable name for consistency.

3 years agoRemove detect_leaks=0 from non-ASAN cmake jobs.
Nathan Moinvaziri [Sat, 26 Mar 2022 15:05:19 +0000 (08:05 -0700)] 
Remove detect_leaks=0 from non-ASAN cmake jobs.

3 years agoFixed error with compare256_unaligned_avx2 undefined if unaligned access is disabled.
Nathan Moinvaziri [Thu, 24 Mar 2022 20:01:21 +0000 (13:01 -0700)] 
Fixed error with compare256_unaligned_avx2 undefined if unaligned access is disabled.

3 years agoFixed signed comparison warning in zng_calloc_aligned.
Nathan Moinvaziri [Sun, 20 Mar 2022 02:41:24 +0000 (19:41 -0700)] 
Fixed signed comparison warning in zng_calloc_aligned.

zutil.c: In function ‘zng_calloc_aligned’:
zutil.c:133:20: warning: comparison of integer expressions of different signedness: ‘int32_t’ {aka ‘int’} and ‘long unsigned int’ [-Wsign-compare]

3 years agoFixed unused opaque variable in aligned alloc test.
Nathan Moinvaziri [Sun, 20 Mar 2022 02:39:06 +0000 (19:39 -0700)] 
Fixed unused opaque variable in aligned alloc test.

test_aligned_alloc.cc: In function ‘void* zng_calloc_unaligned(void*, unsigned int, unsigned int)’:
test_aligned_alloc.cc:14:34: warning: unused parameter ‘opaque’ [-Wunused-parameter]
test_aligned_alloc.cc: In function ‘void zng_cfree_unaligned(void*, void*)’:
test_aligned_alloc.cc:28:32: warning: unused parameter ‘opaque’ [-Wunused-parameter]

3 years agoFixed operator precedence warnings in slide_hash_sse2.
Nathan Moinvaziri [Wed, 16 Mar 2022 21:21:33 +0000 (14:21 -0700)] 
Fixed operator precedence warnings in slide_hash_sse2.

slide_hash_sse2.c(58,5): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
slide_hash_sse2.c(59,5): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence

3 years agoFixed signed/unsigned warning in chunkmemset.
Nathan Moinvaziri [Wed, 16 Mar 2022 21:20:23 +0000 (14:20 -0700)] 
Fixed signed/unsigned warning in chunkmemset.

chunkset_tpl.h(107,24): warning C4018: '>': signed/unsigned mismatch

3 years agoFixed MSVC warnings in chunkcopy_safe.
Nathan Moinvaziri [Wed, 16 Mar 2022 21:10:14 +0000 (14:10 -0700)] 
Fixed MSVC warnings in chunkcopy_safe.

inflate_p.h(244,18): warning C4018: '>': signed/unsigned mismatch
inflate_p.h(234,38): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
inffast.c
inflate_p.h(244,18): warning C4018: '>': signed/unsigned mismatch
inflate_p.h(234,38): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
inflate.c
inflate_p.h(244,18): warning C4018: '>': signed/unsigned mismatch
inflate_p.h(234,38): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data

3 years agoCorrect typo in functable
Rich Ercolani [Fri, 25 Mar 2022 14:06:39 +0000 (10:06 -0400)] 
Correct typo in functable

Now, I could be wrong about this being an error, but I don't see any discussion suggesting this was intended, so...

3 years agoAdd unit tests for compare256 variants.
Nathan Moinvaziri [Fri, 18 Mar 2022 19:10:27 +0000 (12:10 -0700)] 
Add unit tests for compare256 variants.

3 years agoFixed a warning about a comparison of an unsigned with a signed type
Adam Stylinski [Tue, 22 Mar 2022 23:39:41 +0000 (19:39 -0400)] 
Fixed a warning about a comparison of an unsigned with a signed type

3 years agoFix an issue with the ubsan for overflow
Adam Stylinski [Fri, 18 Mar 2022 23:18:10 +0000 (19:18 -0400)] 
Fix an issue with the ubsan for overflow

While this didn't _actually_ cause any issues for us, technically the
_mm512_reduce_add_epi32() intrinsics returns a signed integer and it
does the very last summation in scalar GPRs as signed integers. While
the ALU still did the math properly (the negative representation is the
same addition in hardware, just interpreted differently), the sanitizer
caught window of inputs here definitely outside the range of a signed
integer for this immediate operation.

The solution, as silly as it may seem, would be to implement our own 32
bit horizontal sum function that does all of the work in vector
registers. This allows us to implicitly keep things in vector register
domain and convert at the very end after we've summed the summation.

The compiler's sanitizer doesn't know the wiser and the solution still
results in being correct.

3 years agoUpdate language around ABI compatibility with zlib. #1081
Nathan Moinvaziri [Mon, 21 Mar 2022 18:58:07 +0000 (11:58 -0700)] 
Update language around ABI compatibility with zlib. #1081