summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-05-06 01:24:11 (GMT)
committerYann Collet <cyan@fb.com>2018-05-06 01:24:11 (GMT)
commitaf127334670a5e7b710bbd6adb71aa7c3ef0cd72 (patch)
treebab2c44f789bcd9b92a80802ca4de791e60b6e17 /tests
parentd358e33faa87e0293f27f272a8579de73f4ba938 (diff)
downloadlz4-af127334670a5e7b710bbd6adb71aa7c3ef0cd72.zip
lz4-af127334670a5e7b710bbd6adb71aa7c3ef0cd72.tar.gz
lz4-af127334670a5e7b710bbd6adb71aa7c3ef0cd72.tar.bz2
fixed frametest error
The error can be reproduced using following command : ./frametest -v -i100000000 -s1659 -t31096808 It's actually a bug in the stream LZ4 API, when starting a new stream and providing a first chunk to complete with size < MINMATCH. In which case, the chunk becomes a dictionary. No hash was generated and stored, but the chunk is accessible as default position 0 points to dictStart, and position 0 is still within MAX_DISTANCE. Then, next attempt to read 32-bits from position 0 fails. The issue would have been mitigated by starting from index 64 KB, effectively eliminating position 0 as too far away. The proper fix is to eliminate such "dictionary" as too small. Which is what this patch does.
Diffstat (limited to 'tests')
-rw-r--r--tests/frametest.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/frametest.c b/tests/frametest.c
index 7d69ff7..21d883d 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -740,8 +740,9 @@ static void locateBuffDiff(const void* buff1, const void* buff2, size_t size, un
size_t p=0;
const BYTE* b1=(const BYTE*)buff1;
const BYTE* b2=(const BYTE*)buff2;
+ DISPLAY("locateBuffDiff: looking for error position \n");
if (nonContiguous) {
- DISPLAY("Non-contiguous output test (%i bytes)\n", (int)size);
+ DISPLAY("mode %u: non-contiguous output (%zu bytes), cannot search \n", nonContiguous, size);
return;
}
while (p < size && b1[p]==b2[p]) p++;
@@ -838,6 +839,8 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
size_t const iSize = MIN(sampleMax, (size_t)(iend-ip));
size_t const oSize = LZ4F_compressBound(iSize, prefsPtr);
cOptions.stableSrc = ((FUZ_rand(&randState) & 3) == 1);
+ DISPLAYLEVEL(6, "Sending %zi bytes to compress (stableSrc:%u) \n",
+ iSize, cOptions.stableSrc);
result = LZ4F_compressUpdate(cCtx, op, oSize, ip, iSize, &cOptions);
CHECK(LZ4F_isError(result), "Compression failed (error %i : %s)", (int)result, LZ4F_getErrorName(result));
@@ -882,7 +885,8 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
dOptions.stableDst = FUZ_rand(&randState) & 1;
if (nonContiguousDst==2) dOptions.stableDst = 0; /* overwrite mode */
result = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, &dOptions);
- if (LZ4F_getErrorCode(result) == LZ4F_ERROR_contentChecksum_invalid) locateBuffDiff(srcStart, decodedBuffer, srcSize, nonContiguousDst);
+ if (LZ4F_getErrorCode(result) == LZ4F_ERROR_contentChecksum_invalid)
+ locateBuffDiff(srcStart, decodedBuffer, srcSize, nonContiguousDst);
CHECK(LZ4F_isError(result), "Decompression failed (error %i:%s)", (int)result, LZ4F_getErrorName(result));
XXH64_update(&xxh64, op, (U32)oSize);
totalOut += oSize;