]> git.ipfire.org Git - thirdparty/zstd.git/commit
[libzstd] Fix ZSTD_compress2() for multithreaded compression
authorNick Terrell <terrelln@fb.com>
Tue, 9 Apr 2019 23:24:17 +0000 (16:24 -0700)
committerNick Terrell <terrelln@fb.com>
Tue, 9 Apr 2019 23:24:17 +0000 (16:24 -0700)
commit48a6427d22f290157b8acc3f7c03c0f762a768be
tree530e97757053de86748c518ee8f0454ece4ccfc1
parent7a1fde2957788c07b69772f48d95389118206806
[libzstd] Fix ZSTD_compress2() for multithreaded compression

`ZSTD_compress2()` wouldn't wait for multithreaded compression to
finish. We didn't find this because ZSTDMT will block when it can
compress all in one go, but it can't do that if it doesn't have enough
output space, or if `ZSTD_c_rsyncable` is enabled.

Since we will already sometimes block when using `ZSTD_e_end`, I've
changed `ZSTD_e_end` and `ZSTD_e_flush` to guarantee maximum forward
progress. This simplifies the API, and helps users avoid the easy bug
that was made in `ZSTD_compress2()`

* Found by the libfuzzer fuzzers.
* Added a test case that catches the problem.
* I will make the fuzzers sometimes allocate less than
  `ZSTD_compressBound()` output space.
lib/compress/zstd_compress.c
lib/zstd.h
tests/fuzzer.c