From fc8bd62222c1c40f3451ab8dd13828130654855e Mon Sep 17 00:00:00 2001 From: hadson Date: Wed, 24 Nov 2021 09:41:41 +0800 Subject: [PATCH] fix-a-determinism-bug-with-the-DUBT --- ...-fix-a-determinism-bug-with-the-DUBT.patch | 39 +++++++++++++++++++ zstd.spec | 6 ++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch diff --git a/backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch b/backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch new file mode 100644 index 0000000..2e4cde5 --- /dev/null +++ b/backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch @@ -0,0 +1,39 @@ +diff -Nur zstd-1.5.0/lib/compress/zstd_compress_internal.h new-zstd/lib/compress/zstd_compress_internal.h +--- zstd-1.5.0/lib/compress/zstd_compress_internal.h 2021-05-14 22:59:34.000000000 +0800 ++++ new-zstd/lib/compress/zstd_compress_internal.h 2021-11-22 20:00:33.612480981 +0800 +@@ -199,6 +199,8 @@ + */ + } ZSTD_window_t; + ++#define ZSTD_WINDOW_START_INDEX 2 ++ + typedef struct ZSTD_matchState_t ZSTD_matchState_t; + + #define ZSTD_ROW_HASH_CACHE_SIZE 8 /* Size of prefetching hash cache for row-based matchfinder */ +@@ -884,9 +886,9 @@ + + MEM_STATIC U32 ZSTD_window_isEmpty(ZSTD_window_t const window) + { +- return window.dictLimit == 1 && +- window.lowLimit == 1 && +- (window.nextSrc - window.base) == 1; ++ return window.dictLimit == ZSTD_WINDOW_START_INDEX && ++ window.lowLimit == ZSTD_WINDOW_START_INDEX && ++ (window.nextSrc - window.base) == ZSTD_WINDOW_START_INDEX; + } + + /** +@@ -1151,9 +1153,10 @@ + ZSTD_memset(window, 0, sizeof(*window)); + window->base = (BYTE const*)""; + window->dictBase = (BYTE const*)""; +- window->dictLimit = 1; /* start from 1, so that 1st position is valid */ +- window->lowLimit = 1; /* it ensures first and later CCtx usages compress the same */ +- window->nextSrc = window->base + 1; /* see issue #1241 */ ++ ZSTD_STATIC_ASSERT(ZSTD_DUBT_UNSORTED_MARK < ZSTD_WINDOW_START_INDEX); ++ window->dictLimit = ZSTD_WINDOW_START_INDEX; /* start from >0, so that 1st position is valid */ ++ window->lowLimit = ZSTD_WINDOW_START_INDEX; /* it ensures first and later CCtx usages compress the same */ ++ window->nextSrc = window->base + ZSTD_WINDOW_START_INDEX; /* see issue #1241 */ + window->nbOverflowCorrections = 0; + } + diff --git a/zstd.spec b/zstd.spec index 57439fb..9d2420c 100644 --- a/zstd.spec +++ b/zstd.spec @@ -2,7 +2,7 @@ Name: zstd Version: 1.5.0 -Release: 8 +Release: 9 Summary: A fast lossless compression algorithm License: BSD and GPLv2 URL: https://github.com/facebook/zstd @@ -13,6 +13,7 @@ Patch2: backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files Patch3: backport-zstd-1.5.0-patch-3-remove-invalid-test.patch Patch4: backport-zstd-1.5.0-patch-4-limit-train-samples.patch Patch5: patch-5-add-test-case-survive-a-list-of-files-which-long-file-name-length.patch +Patch6: backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch BuildRequires: gtest-devel gcc-c++ pkg-config @@ -91,6 +92,9 @@ install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1 %{_mandir}/man1/*.1* %changelog +* Mon Nov 22 2021 wangshenglong - 1.5.0.9 +* fix a determinism bug with the DUBT + * Thu Nov 18 2021 zhangxiao - 1.5.0.8 * add test case survive a list of files which long file name length