]> git.ipfire.org Git - thirdparty/zstd.git/commit
[zstdmt] Fix determinism issue with rsyncable mode
authorNick Terrell <terrelln@fb.com>
Tue, 6 Oct 2020 02:14:19 +0000 (19:14 -0700)
committerNick Terrell <terrelln@fb.com>
Mon, 12 Oct 2020 19:55:17 +0000 (12:55 -0700)
commitefff5d8b2df02e2eed5decea1b321faef6b14931
tree397d46831726a2b1a48eb669794d4c4b7d00c032
parentede4f97153324bf640cdc9020eed1a85edd18ad4
[zstdmt] Fix determinism issue with rsyncable mode

The problem occurs in this scenario:
1. We find a synchronization point.
2. We attmept to create the job.
3. We fail because the job table is full: `mtctx->nextJobID > mtctx->doneJobID + mtctx->jobIDMask`.
4. We call `ZSTDMT_compressStream_generic` again.
5. We forget that we're at a sync point already, and we continue looking
   for the next sync point.

This fix is to detect if we're currently paused at a sync point, and if
we are then don't load any more input.

Caught by zstreamtest. I modified it to make the bug occur more often
(~1/100K -> ~1/200) and verified that it is fixed after. I then ran a
few hundred thousand unmodified zstreamtest iterations to verify.
lib/compress/zstdmt_compress.c