]> git.ipfire.org Git - thirdparty/zstd.git/log
thirdparty/zstd.git
3 years agoOn more mistake (Node -> Note) 3095/head
Dominique Pelle [Sat, 12 Mar 2022 23:08:55 +0000 (00:08 +0100)] 
On more mistake (Node -> Note)

3 years agoTypo and grammar fixes
Dominique Pelle [Sat, 12 Mar 2022 07:52:40 +0000 (08:52 +0100)] 
Typo and grammar fixes

3 years agoMerge pull request #3088 from cyberknight777/dev
Nick Terrell [Fri, 11 Mar 2022 18:01:11 +0000 (10:01 -0800)] 
Merge pull request #3088 from cyberknight777/dev

[contrib][linux] Fix a warning in zstd_reset_cstream()

3 years agoMerge pull request #3093 from dirkmueller/cli_tests_fixup
Nick Terrell [Thu, 10 Mar 2022 18:41:52 +0000 (10:41 -0800)] 
Merge pull request #3093 from dirkmueller/cli_tests_fixup

Handle newer less versions in zstdless testing

3 years agoHandle newer less versions in zstdless testing 3093/head
Dirk Müller [Wed, 9 Mar 2022 23:25:05 +0000 (00:25 +0100)] 
Handle newer less versions in zstdless testing

Newer less versions appear to have changed how stderr
and stdout are showing error messages. hardcode the
expected behavior to make the tests pass with any less version.

Also set locale to C so that the strings are matching.

3 years ago[contrib][linux] Make zstd_reset_cstream() functionally identical to ZSTD_resetCStream() 3088/head
Cyber Knight [Thu, 10 Mar 2022 07:32:13 +0000 (15:32 +0800)] 
[contrib][linux] Make zstd_reset_cstream() functionally identical to ZSTD_resetCStream()

- As referenced by Nick Terrelln ~ the ZSTD maintainer in the linux kernel, making zstd_reset_cstream() functionally identical to ZSTD_resetCStream() would be the perfect way to fix the warning without touching any core functions or breaking other parts of the code.

Suggested-by: Nick Terrell <terrelln@fb.com>
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
3 years agoMerge pull request #3092 from terrelln/2022-03-09-decoder-errata-doc
Nick Terrell [Wed, 9 Mar 2022 23:10:29 +0000 (15:10 -0800)] 
Merge pull request #3092 from terrelln/2022-03-09-decoder-errata-doc

[doc] Add decompressor errata document

3 years ago[doc] Add decompressor errata document 3092/head
Nick Terrell [Wed, 9 Mar 2022 22:39:13 +0000 (14:39 -0800)] 
[doc] Add decompressor errata document

Add a document that lists the known bugs in the decoder where valid
frames are rejected, along with the version that they were fixed.

3 years agoMerge pull request #3059 from dirkmueller/gzip_fast_best
Felix Handte [Tue, 8 Mar 2022 20:32:06 +0000 (15:32 -0500)] 
Merge pull request #3059 from dirkmueller/gzip_fast_best

Implement more gzip compatibility (#3037)

3 years agoMerge pull request #3079 from niamster/cmake-compat-5
Yann Collet [Tue, 8 Mar 2022 08:21:23 +0000 (00:21 -0800)] 
Merge pull request #3079 from niamster/cmake-compat-5

build:cmake: enable ZSTD legacy support by default

3 years ago[contrib][linux] Use ZSTD_CCtx_setPledgedSrcSize() instead of ZSTD_CCtx_reset()
Cyber Knight [Tue, 8 Mar 2022 05:38:06 +0000 (13:38 +0800)] 
[contrib][linux] Use ZSTD_CCtx_setPledgedSrcSize() instead of ZSTD_CCtx_reset()

- The previous patch throws the following warning:

 ../linux/lib/zstd/zstd_compress_module.c: In function ‘zstd_reset_cstream’:
../linux/lib/zstd/zstd_compress_module.c:136:34: error: enum conversion when passing argument 2 of ‘ZSTD_CCtx_reset’ is invalid in C++ [-Werror=c++-compat]
  136 |  return ZSTD_CCtx_reset(cstream, pledged_src_size);
      |                                  ^~~~~~~~~~~~~~~~
In file included from ../linux/include/linux/zstd.h:26,
                 from ../linux/lib/zstd/zstd_compress_module.c:15:
../linux/include/linux/zstd_lib.h:501:20: note: expected ‘ZSTD_ResetDirective’ {aka ‘enum <anonymous>’} but argument is of type ‘long long unsigned int’
  501 | ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset);
      |                    ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Since we have a choice to either use ZSTD_CCtx_reset or ZSTD_CCtx_setPledgedSrcSize instead of ZSTD_resetCStream, let's switch to ZSTD_CCtx_setPledgedSrcSize to not have any unnecessary warns alongside the kernel build and CI test build.

Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
3 years ago[contrib][linux] Fix a warning in zstd_reset_cstream()
Cyber Knight [Mon, 7 Mar 2022 03:55:33 +0000 (11:55 +0800)] 
[contrib][linux] Fix a warning in zstd_reset_cstream()

- This fixes the below warning:

../lib/zstd/zstd_compress_module.c: In function 'zstd_reset_cstream':
../lib/zstd/zstd_compress_module.c:136:9: warning: 'ZSTD_resetCStream' is deprecated [-Wdeprecated-declarations]
  136 |         return ZSTD_resetCStream(cstream, pledged_src_size);
      |         ^~~~~~
In file included from ../include/linux/zstd.h:26,
                 from ../lib/zstd/zstd_compress_module.c:15:
../include/linux/zstd_lib.h:2277:8: note: declared here
 2277 | size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
      |        ^~~~~~~~~~~~~~~~~

ZSTD_resetCstream is deprecated and zstd_CCtx_reset is suggested to use hence let's switch to it.

Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
3 years agoMerge pull request #3060 from rex4539/typos
Yann Collet [Sat, 5 Mar 2022 22:21:58 +0000 (14:21 -0800)] 
Merge pull request #3060 from rex4539/typos

Fix typos

3 years agoFix typos 3060/head
Dimitris Apostolou [Wed, 9 Feb 2022 06:58:23 +0000 (08:58 +0200)] 
Fix typos

3 years agofix the assertion in readLinesFromFile (#3084)
Xi Ruoyao [Fri, 4 Mar 2022 19:56:44 +0000 (03:56 +0800)] 
fix the assertion in readLinesFromFile (#3084)

* fix the assertion in readLinesFromFile

When the file is not terminated by endline, readLineFromFile will append
a '\0' for the last line.  In this case pos + lineLength == dstCapacity.

* test: don't print very long text garbage

3 years agoMerge pull request #3080 from TocarIP/tokarip/static_bmi2
Yann Collet [Thu, 3 Mar 2022 20:49:40 +0000 (12:49 -0800)] 
Merge pull request #3080 from TocarIP/tokarip/static_bmi2

Enable STATIC_BMI2 for gcc/clang

3 years agoEnable STATIC_BMI2 for gcc/clang 3080/head
Ilya Tokar [Tue, 1 Mar 2022 23:49:10 +0000 (18:49 -0500)] 
Enable STATIC_BMI2 for gcc/clang

Some usage (e.g. BIT_getLowerBit) uses it without checking for MSVC,
so enabling for clang gives a small performance boost.

3 years agoFix CI failures by adding apt-get update to Github Actions (#3082)
Elliot Gorokhovsky [Thu, 3 Mar 2022 19:52:06 +0000 (14:52 -0500)] 
Fix CI failures by adding apt-get update to Github Actions (#3082)

* Fix CI failures by adding apt-get update to Makefile

* Fix travis failure caused by apt-get update

* Move apt-get update from Makefile to Github Actions .yml

* Revert .travis.yml change

* Fix typo

3 years agoMerge pull request #3081 from terrelln/dict-load-zero
Nick Terrell [Wed, 2 Mar 2022 20:58:51 +0000 (12:58 -0800)] 
Merge pull request #3081 from terrelln/dict-load-zero

[programs] Fix infinite loop when empty input is passed to trainer

3 years ago[programs] Fix infinite loop when empty input is passed to trainer 3081/head
Nick Terrell [Wed, 2 Mar 2022 19:04:04 +0000 (11:04 -0800)] 
[programs] Fix infinite loop when empty input is passed to trainer

When an empty input file was passed to the dictionary trainer, it would infinite loop.
The added test case exposes the bug, and is fixed with this PR.

3 years agobuild:cmake: enable ZSTD legacy support by default 3079/head
Dmytro Milinevskyi [Tue, 1 Mar 2022 17:29:47 +0000 (18:29 +0100)] 
build:cmake: enable ZSTD legacy support by default

3 years agoMerge pull request #3075 from TocarIP/tokarip/bzhi
Elliot Gorokhovsky [Thu, 24 Feb 2022 21:52:48 +0000 (16:52 -0500)] 
Merge pull request #3075 from TocarIP/tokarip/bzhi

Use helper function for bit manipulations.

3 years agoUse helper function for bit manipulations. 3075/head
Ilya Tokar [Wed, 23 Feb 2022 22:59:56 +0000 (17:59 -0500)] 
Use helper function for bit manipulations.

We already have BIT_getLowerBits, so use it. Benefits are 2fold:
1) Somewhat cleaner code
2) We are now using bzhi instructions, when available. Performance
delta is too small for microbenchmarks, but avoiding load still helps
larger applications, by reducing data cache pressure.

3 years agoMerge pull request #3045 from embg/asm_refactor
Elliot Gorokhovsky [Thu, 17 Feb 2022 18:08:08 +0000 (13:08 -0500)] 
Merge pull request #3045 from embg/asm_refactor

Refactor bitwise intrinsics

3 years agoReplace XOR with subtraction for readability 3045/head
Elliot Gorokhovsky [Wed, 16 Feb 2022 21:49:42 +0000 (16:49 -0500)] 
Replace XOR with subtraction for readability

3 years agoFix fuzzer.c nits and replace CLZ fallback
Elliot Gorokhovsky [Wed, 16 Feb 2022 16:16:55 +0000 (11:16 -0500)] 
Fix fuzzer.c nits and replace CLZ fallback

3 years agoAdd back check to prevent Win32 static analysis issues
Elliot Gorokhovsky [Tue, 15 Feb 2022 16:41:09 +0000 (11:41 -0500)] 
Add back check to prevent Win32 static analysis issues

3 years agoAdd tests for bitwise intrinsics
Elliot Gorokhovsky [Mon, 14 Feb 2022 22:15:30 +0000 (17:15 -0500)] 
Add tests for bitwise intrinsics

3 years agobits.h refactor and bugfix
Elliot Gorokhovsky [Mon, 14 Feb 2022 21:08:00 +0000 (16:08 -0500)] 
bits.h refactor and bugfix

3 years agoFix nits
Elliot Gorokhovsky [Mon, 7 Feb 2022 17:22:04 +0000 (12:22 -0500)] 
Fix nits

3 years agoPull out software fallbacks
Elliot Gorokhovsky [Mon, 31 Jan 2022 19:59:51 +0000 (14:59 -0500)] 
Pull out software fallbacks

3 years agoMove bitwise builtins into bits.h
Elliot Gorokhovsky [Fri, 21 Jan 2022 18:29:14 +0000 (11:29 -0700)] 
Move bitwise builtins into bits.h

3 years agoMerge pull request #3063 from embg/largeNbDicts
Elliot Gorokhovsky [Fri, 11 Feb 2022 18:55:35 +0000 (13:55 -0500)] 
Merge pull request #3063 from embg/largeNbDicts

Bugfix and new features for largeNbDicts benchmark

3 years agoBugfix and new features for largeNbDicts benchmark 3063/head
Elliot Gorokhovsky [Tue, 8 Feb 2022 16:49:31 +0000 (11:49 -0500)] 
Bugfix and new features for largeNbDicts benchmark

3 years agoMerge pull request #3054 from ooosssososos/patch-1
Yann Collet [Fri, 11 Feb 2022 16:13:09 +0000 (08:13 -0800)] 
Merge pull request #3054 from ooosssososos/patch-1

[trace] Add aarch64 to supported architectures for zstd_trace

3 years agoImplement more gzip compatibility (#3037) 3059/head
Dirk Müller [Tue, 8 Feb 2022 20:32:42 +0000 (21:32 +0100)] 
Implement more gzip compatibility (#3037)

-n --no-name is the current behavior already, so we can implement
this as a noop.

--best is an alias for -9 in gzip

add basic cli tests.

3 years agoMerge pull request #3061 from embg/debug_ci_windows
Elliot Gorokhovsky [Wed, 9 Feb 2022 21:29:56 +0000 (16:29 -0500)] 
Merge pull request #3061 from embg/debug_ci_windows

Debug Windows CI failures

3 years agoReplace "windows-latest" with "windows-2019" in CI workflows 3061/head
Elliot Gorokhovsky [Wed, 9 Feb 2022 19:44:46 +0000 (14:44 -0500)] 
Replace "windows-latest" with "windows-2019" in CI workflows

3 years agoMove zstdgrep and zstdless tests to cli-tests (#3057)
binhdvo [Wed, 9 Feb 2022 16:21:33 +0000 (11:21 -0500)] 
Move zstdgrep and zstdless tests to cli-tests (#3057)

* Move zstdgrep and zstdless tests to cli-tests

Co-authored-by: Binh Vo <binhvo@fb.com>
3 years agoMerge pull request #3055 from terrelln/cli-test-symlinks
Nick Terrell [Tue, 8 Feb 2022 00:16:50 +0000 (16:16 -0800)] 
Merge pull request #3055 from terrelln/cli-test-symlinks

[cli-tests] Fix zstd symlinks

3 years ago[cli-tests] Fix zstd symlinks 3055/head
Nick Terrell [Mon, 7 Feb 2022 23:20:42 +0000 (15:20 -0800)] 
[cli-tests] Fix zstd symlinks

The zstd symlinks, notably `zstdcat`, weren't working as expected
because only the `tests/cli-tests/bin/zstd` wrapper was symlinked. We
still invoked `zstd` with the name `zstd`. The fix is to create a
directory of zstd symlinks in `tests/cli-tests/bin/symlinks` for each
name that zstd recognizes. And when `tets/cli-tests/bin/zstd` is
invoked, it selects the correct symlink to call.

See the test `zstd-cli/zstdcat.sh` for an example of how it would work.

3 years ago[trace] Add aarch64 to supported architectures for zstd_trace 3054/head
Oscar Shi [Mon, 7 Feb 2022 22:41:07 +0000 (14:41 -0800)] 
[trace] Add aarch64 to supported architectures for zstd_trace

Arm Toolchain should support weak symbols

3 years agoMerge pull request #3050 from shadchin/patch-1
Nick Terrell [Fri, 4 Feb 2022 19:23:19 +0000 (11:23 -0800)] 
Merge pull request #3050 from shadchin/patch-1

Select legacy level for cmake

3 years agoMerge pull request #3042 from u1f35c/fix2968
Yann Collet [Fri, 4 Feb 2022 15:50:58 +0000 (07:50 -0800)] 
Merge pull request #3042 from u1f35c/fix2968

Fix required decompression memory usage reported by -vv + --long

3 years agoMerge pull request #3046 from rex4539/typos
Yann Collet [Fri, 4 Feb 2022 15:50:25 +0000 (07:50 -0800)] 
Merge pull request #3046 from rex4539/typos

Fix typos

3 years agoSelect legacy level for cmake 3050/head
Alexander Shadchin [Fri, 4 Feb 2022 11:24:58 +0000 (14:24 +0300)] 
Select legacy level for cmake

3 years agoMacos playtest envvars fix (#3035)
Yonatan Komornik [Fri, 4 Feb 2022 02:42:20 +0000 (18:42 -0800)] 
Macos playtest envvars fix (#3035)

* playtests.sh: fix for a bug in macos' /bin/sh that persists temporary env vars when introduced before function calls
* cli-tests/run.py: Do not use existing ZSTD* envvars

3 years agoAdd rails for huffman table log calculation (#3047)
binhdvo [Wed, 2 Feb 2022 20:12:48 +0000 (15:12 -0500)] 
Add rails for huffman table log calculation (#3047)

3 years agoFix typos 3046/head
Dimitris Apostolou [Wed, 2 Feb 2022 17:32:31 +0000 (19:32 +0200)] 
Fix typos

3 years agoFix required decompression memory usage reported by -vv + --long 3042/head
Jonathan McDowell [Tue, 1 Feb 2022 11:20:30 +0000 (03:20 -0800)] 
Fix required decompression memory usage reported by -vv + --long

The use of --long alters the window size internally in the underlying
library (lib/compress/zstd_compress.c:ZSTD_getCParamsFromCCtxParams),
which changes the memory required for decompression. This means that the
reported requirement from the zstd binary when -vv is specified is
incorrect.

A full fix for this would be to add an API call to be able to retrieve
the required decompression memory from the library, but as a
lighterweight fix we can just take account of the fact we've enabled
long mode and update our verbose output appropriately.

Fixes #2968

3 years agoMerge pull request #3040 from facebook/fix44239
Yann Collet [Tue, 1 Feb 2022 21:33:01 +0000 (13:33 -0800)] 
Merge pull request #3040 from facebook/fix44239

fix 44239

3 years agofix 44239 3040/head
Yann Collet [Mon, 31 Jan 2022 17:34:04 +0000 (09:34 -0800)] 
fix 44239

credit to oss-fuzz

This issue could happen when using the new Sequence Compression API in Explicit Delimiter Mode
with a too small dstCapacity.
In which case, there was one place where the buffer size wasn't checked.

3 years agoMerge pull request #3036 from facebook/fix44168
Yann Collet [Tue, 1 Feb 2022 18:10:32 +0000 (10:10 -0800)] 
Merge pull request #3036 from facebook/fix44168

fixed bug 44168

3 years agoMerge branch 'dev' into fix44168 3036/head
Yann Collet [Tue, 1 Feb 2022 01:31:55 +0000 (17:31 -0800)] 
Merge branch 'dev' into fix44168

3 years agoTravis CI: fix by installing pip compatible with python 3.6 (#3041)
Yonatan Komornik [Tue, 1 Feb 2022 00:49:49 +0000 (16:49 -0800)] 
Travis CI: fix by installing pip compatible with python 3.6 (#3041)

Pip install script no longer supports python3.6 by default, switched to a script that does.

3 years agoupdate sequence_compression_api fuzzer test
Yann Collet [Tue, 1 Feb 2022 00:17:11 +0000 (16:17 -0800)] 
update sequence_compression_api fuzzer test

to check for under-sized dstCapacity.

3 years agoAsyncIO compression part 2 - added async read and asyncio to compression code (#3022)
Yonatan Komornik [Mon, 31 Jan 2022 23:43:41 +0000 (15:43 -0800)] 
AsyncIO compression part 2 - added async read and asyncio to compression code (#3022)

* Compression asyncio:
- Added asyncio functionality for compression flow
- Added ReadPool for async reads, implemented in both comp and decomp flows

3 years agoMerge pull request #3020 from terrelln/cli-tests
Nick Terrell [Mon, 31 Jan 2022 18:02:27 +0000 (10:02 -0800)] 
Merge pull request #3020 from terrelln/cli-tests

Add new CLI testing platform

3 years agoFix static analysis false-positives 3020/head
Nick Terrell [Sun, 30 Jan 2022 20:16:16 +0000 (12:16 -0800)] 
Fix static analysis false-positives

* It couldn't detect that the `fastCoverParams` can't be non-null, since it was just an assertion.
* It thought we were accesing `wksp->dtable` beyond the bounds because we were using it to set the `workSpace` value. Instead, compute the workspace size used in a different way.

3 years agofixed bug 44168
Yann Collet [Sun, 30 Jan 2022 00:23:21 +0000 (16:23 -0800)] 
fixed bug 44168

discovered by oss-fuzz

It's a bug in the test itself :
ZSTD_compressBound() as an upper bound of the compress size
only works for data compressed "normally".
But in situations where many flushes are forcefully introduced,
this creates many more blocks,
each of which has a potential to increase the size by 3 bytes.
In extreme cases (lots of small incompressible blocks), the expansion can go beyond ZSTD_compressBound().

This situation is similar when using the CompressSequences() API
with Explicit Block Delimiters.
In which case, each explicit block acts like a deliberate flush.
When employed by a fuzzer, it's possible to generate scenarios like the one described above,
with tons of incompressible blocks of small sizes,
thus going beyond ZSTD_compressBound().

fix : when using Explicit Block Delimiters, use a larger bound, to account for this scenario.

3 years agoMerge pull request #3027 from brailovich/dev
Yann Collet [Sat, 29 Jan 2022 23:40:43 +0000 (15:40 -0800)] 
Merge pull request #3027 from brailovich/dev

fix for -r on empty directory

3 years agoMerge pull request #3030 from terrelln/verbose-version
Yann Collet [Sat, 29 Jan 2022 23:40:09 +0000 (15:40 -0800)] 
Merge pull request #3030 from terrelln/verbose-version

Print zlib/lz4/lzma library versions in verbose version output

3 years agominor refactor to blocksplit
Yann Collet [Thu, 27 Jan 2022 19:06:16 +0000 (11:06 -0800)] 
minor refactor to blocksplit

notably simplication of ZSTD_deriveSeqStoreChunk()

3 years agoMerge pull request #3034 from facebook/fix44122
Yann Collet [Fri, 28 Jan 2022 00:01:39 +0000 (16:01 -0800)] 
Merge pull request #3034 from facebook/fix44122

fix 44122 test error

3 years agofix 44122 test error 3034/head
Yann Collet [Thu, 27 Jan 2022 22:54:18 +0000 (14:54 -0800)] 
fix 44122 test error

It's a bug in the test itself, in exceptional circumstances (no more space for additional sequence).

There should be enough room for all cases to work fine from now on,
and if not, we have an additional `assert()` to catch that situation.

3 years ago[CI] Hook cli-tests up to CI
Nick Terrell [Mon, 24 Jan 2022 21:52:08 +0000 (13:52 -0800)] 
[CI] Hook cli-tests up to CI

Add cli-tests to `make test`. This adds a `python3` dependency to `make
test`, but not `make check`. We could make this dependency optional by
skipping the tests if `python3` is not present.

3 years ago[test] Add new CLI testing platform
Nick Terrell [Tue, 18 Jan 2022 21:31:27 +0000 (13:31 -0800)] 
[test] Add new CLI testing platform

Adds the new CLI testing platform that I'm proposing.
See the added `README.md` for details.

3 years ago[datagen] Remove extra newline printed
Nick Terrell [Fri, 21 Jan 2022 06:46:45 +0000 (22:46 -0800)] 
[datagen] Remove extra newline printed

`datagen` was printing a `\n` even when it had no other output. Raise
the output level for the final `\n` to the minimum output level used.

This minor bug was caught by the new testing framework.

3 years ago[zstdcli] Fix option detection for --auto-threads
Nick Terrell [Fri, 21 Jan 2022 06:45:03 +0000 (22:45 -0800)] 
[zstdcli] Fix option detection for --auto-threads

The option `--auto-threads` should still be accepted and parsed, even if
`ZSTD_MULTITHREAD` is not defined. It doesn't mean anything, but we
should still accept the option. Since we want scripts to be able to work
generically.

This bug was caught by tests I added to the new testing framework.

3 years ago[dibio] Fix assertion triggered by no inputs
Nick Terrell [Fri, 21 Jan 2022 06:41:47 +0000 (22:41 -0800)] 
[dibio] Fix assertion triggered by no inputs

Passing 0 inputs to `DiB_shuffle()` caused an assertion failure where
it should just return.

A test is added in a later commit, with the initial introduction of the
new testing framework.

Fixes #3007.

3 years agoMerge pull request #3033 from facebook/fix44108
Yann Collet [Thu, 27 Jan 2022 18:57:48 +0000 (10:57 -0800)] 
Merge pull request #3033 from facebook/fix44108

fix issue 44108

3 years agoUpdate playTests.sh 3027/head
brailovich [Thu, 27 Jan 2022 16:22:05 +0000 (08:22 -0800)] 
Update playTests.sh

combination of -r with empty folder simplified to comply with sh compatibility tests

3 years agoMerge pull request #2974 from facebook/fix2966_part3
Yann Collet [Thu, 27 Jan 2022 14:14:04 +0000 (06:14 -0800)] 
Merge pull request #2974 from facebook/fix2966_part3

Lazy parameters adaptation (part 1 - ZSTD_c_stableInBuffer)

3 years agofix issue 44108 3033/head
Yann Collet [Thu, 27 Jan 2022 13:13:45 +0000 (05:13 -0800)] 
fix issue 44108

credit to oss-fuzz

In rare circumstances, the block-splitter might cut a block at the exact beginning of a repcode.
In which case, since litlength=0, if the repcode expected 1+ literals in front, its signification changes.
This scenario is controlled in ZSTD_seqStore_resolveOffCodes(),
and the repcode is transformed into a raw offset when its new meaning is incorrect.

In more complex scenarios, the previous block might be emitted as uncompressed after all,
thus modifying the expected repcode history.
In the case discovered by oss-fuzz, the first block is emitted as uncompressed,
so the repcode history remains at default values: 1,4,8.

But since the starting repcode is repcode3, and the literal length is == 0,
its meaning is : = repcode1 - 1.
Since repcode1==1, it results in an offset value of 0, which is invalid.

So that's what the `assert()` was verifying : the result of the repcode translation should be a valid offset.

But actually, it doesn't matter, because this result will then be compared to reality,
and since it's an invalid offset, it will necessarily be discarded if incorrect,
then the repcode will be replaced by a raw offset.

So the `assert()` is not useful.
Furthermore, it's incorrect, because it assumes this situation cannot happen, but it does, as described in above scenario.

3 years agoUpdate playTests.sh
brailovich [Thu, 27 Jan 2022 02:56:52 +0000 (18:56 -0800)] 
Update playTests.sh

3 years agomore usage of new error code stabilityCondition_notRespected 2974/head
Yann Collet [Thu, 27 Jan 2022 02:04:52 +0000 (18:04 -0800)] 
more usage of new error code stabilityCondition_notRespected

as suggested by @terrelln

3 years agoPrint zlib/lz4/lzma library versions in verbose version output 3030/head
Nick Terrell [Thu, 27 Jan 2022 01:55:26 +0000 (17:55 -0800)] 
Print zlib/lz4/lzma library versions in verbose version output

Knowing the version of zlib/lz4/lzma we're linking against is very
useful for debugging issues with those libraries, so print it out in the
verbosity 4 version output.

Also print this information at the top of `playTests.sh`.

3 years agoMerge pull request #3019 from facebook/huf_traces
Yann Collet [Thu, 27 Jan 2022 02:02:05 +0000 (18:02 -0800)] 
Merge pull request #3019 from facebook/huf_traces

More traces to improved debugging of literals compression

3 years agoUpdate playTests.sh
brailovich [Thu, 27 Jan 2022 00:53:11 +0000 (16:53 -0800)] 
Update playTests.sh

3 years agoUpdate zstdcli.c
brailovich [Thu, 27 Jan 2022 00:51:18 +0000 (16:51 -0800)] 
Update zstdcli.c

3 years agoremoved new huffman depth heuristic 3019/head
Yann Collet [Wed, 26 Jan 2022 23:22:06 +0000 (15:22 -0800)] 
removed new huffman depth heuristic

results are now identical to before this PR

3 years agointroduced LitHufLog constant
Yann Collet [Sat, 22 Jan 2022 01:13:33 +0000 (17:13 -0800)] 
introduced LitHufLog constant

which properly represents the maximum bit size of compressed literals (11) as defined in the specification.

To be preferred from HUF_TABLELOG_DEFAULT which represents the same value but by accident.

Name selected to keep the same convention as existing width definitions,
MLFSELog, LLFSELog and OffFSELog.

3 years agorenamed HufLog into ZSTD_HUFFDTABLE_CAPACITY_LOG
Yann Collet [Sat, 22 Jan 2022 01:03:48 +0000 (17:03 -0800)] 
renamed HufLog into ZSTD_HUFFDTABLE_CAPACITY_LOG

old name was not descriptive and actually misleading

3 years agomoved HufLog to lib/decompress
Yann Collet [Sat, 22 Jan 2022 00:40:30 +0000 (16:40 -0800)] 
moved HufLog to lib/decompress

it's only used to size decompression tables

3 years agoonly declare debug functions in debug mode
Yann Collet [Sat, 22 Jan 2022 00:14:25 +0000 (16:14 -0800)] 
only declare debug functions in debug mode

3 years agoproper max limit to 11
Yann Collet [Fri, 21 Jan 2022 06:19:35 +0000 (22:19 -0800)] 
proper max limit to 11

3 years agoupdate regression tests
Yann Collet [Fri, 21 Jan 2022 05:59:46 +0000 (21:59 -0800)] 
update regression tests

minor compression ratio benefits in some cases,
no compression ratio regression in the measured scenarios.

3 years agoimproved compression of literals in specific corner cases
Yann Collet [Fri, 21 Jan 2022 05:24:33 +0000 (21:24 -0800)] 
improved compression of literals in specific corner cases

In rare cases, the default huffman depth selector is a bit too harsh,
requiring brutal adaptations to the tree,
resulting is some loss of compression ratio.
This new heuristic avoids the worse cases, favoring compression ratio.

As an example, compression of a specific distribution of 771 literals
is now improved to 441 bytes, from 601 bytes before.

3 years agoadding traces to better track processing of literals
Yann Collet [Fri, 21 Jan 2022 05:23:48 +0000 (21:23 -0800)] 
adding traces to better track processing of literals

3 years agoMerge pull request #3023 from facebook/fix_seqCompress_withDelimiter
Yann Collet [Wed, 26 Jan 2022 22:15:28 +0000 (14:15 -0800)] 
Merge pull request #3023 from facebook/fix_seqCompress_withDelimiter

fix sequence compression API in Explicit Delimiter mode

3 years agoadded ZSTD_compressStream2() + ZSTD_c_stableInBuffer test
Yann Collet [Wed, 26 Jan 2022 21:33:04 +0000 (13:33 -0800)] 
added ZSTD_compressStream2() + ZSTD_c_stableInBuffer test

3 years agoadded helper function inBuffer_forEndFlush()
Yann Collet [Wed, 26 Jan 2022 19:05:57 +0000 (11:05 -0800)] 
added helper function inBuffer_forEndFlush()

3 years agoconverted checks into user validation generating error codes
Yann Collet [Wed, 26 Jan 2022 18:43:50 +0000 (10:43 -0800)] 
converted checks into user validation generating error codes

had to create a new error code for this condition,
none of the existing ones were fitting enough.

3 years agoadded streaming test starting from non-0 pos
Yann Collet [Wed, 26 Jan 2022 18:30:33 +0000 (10:30 -0800)] 
added streaming test starting from non-0 pos

3 years agofix extended case combining stableInBuffer with continue() and flush() modes
Yann Collet [Tue, 25 Jan 2022 06:57:55 +0000 (22:57 -0800)] 
fix extended case combining stableInBuffer with continue() and flush() modes

3 years agobetter consistency in accessing @input
Yann Collet [Mon, 24 Jan 2022 22:45:22 +0000 (14:45 -0800)] 
better consistency in accessing @input

as suggested by @terrelln.

Also : commented zstreamtest more
to ensure ZSTD_stableInBuffer is tested/

3 years agopretend consuming input to provide a sense of forward progress
Yann Collet [Thu, 6 Jan 2022 00:34:10 +0000 (16:34 -0800)] 
pretend consuming input to provide a sense of forward progress

3 years agofixed incorrect comment
Yann Collet [Wed, 5 Jan 2022 21:21:43 +0000 (13:21 -0800)] 
fixed incorrect comment

3 years agominor behavior refinements
Yann Collet [Mon, 3 Jan 2022 04:06:46 +0000 (20:06 -0800)] 
minor behavior refinements

specifically, there is no obligation to start streaming compression with pos=0.
stableSrc mode is now compatible with this setup.

3 years agomake stableSrc compatible with regular streaming API
Yann Collet [Sun, 2 Jan 2022 07:15:34 +0000 (23:15 -0800)] 
make stableSrc compatible with regular streaming API

including flushStream().

Now the only condition is for `input.size` to continuously grow.