diff --git a/.travis.yml b/.travis.yml index 846f12175..2d5a73a6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ env: - ZSTD_TRAVIS_CI_ENV="-C programs test-zstd_nolegacy" - ZSTD_TRAVIS_CI_ENV=usan - ZSTD_TRAVIS_CI_ENV=asan + - ZSTD_TRAVIS_CI_ENV=asan32 - ZSTD_TRAVIS_CI_ENV="-C programs valgrindTest" matrix: diff --git a/Makefile b/Makefile index 9e7b70ee0..abec33f86 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ # ################################################################ # Version number -export VERSION := 0.4.3 +export VERSION := 0.4.4 PRGDIR = programs ZSTDDIR = lib @@ -96,6 +96,9 @@ usan: clean asan: clean $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address" +asan32: clean + $(MAKE) -C $(PRGDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address" + uasan: clean $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined" diff --git a/NEWS b/NEWS index e7785b51c..50b26fb95 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ v0.4.4 +Fixed : high compression modes for Windows 32 bits new : windows DLL project, thanks to Christophe Chevalier v0.4.3 : diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index 046c03541..11e613882 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -1026,7 +1026,7 @@ static U32 ZSTD_insertBt1(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, co size_t commonLengthSmaller=0, commonLengthLarger=0; const BYTE* const base = zc->base; const BYTE* match = base + matchIndex; - U32 current = (U32)(ip-base); + const U32 current = (U32)(ip-base); const U32 btLow = btMask >= current ? 0 : current - btMask; U32* smallerPtr = bt + 2*(current&btMask); U32* largerPtr = bt + 2*(current&btMask) + 1; @@ -1040,7 +1040,7 @@ static U32 ZSTD_insertBt1(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, co return (U32)(rleLength - mls); } - hashTable[h] = (U32)(ip - base); /* Update Hash Table */ + hashTable[h] = current; /* Update Hash Table */ while (nbCompares-- && (matchIndex > windowLow)) { @@ -1103,7 +1103,7 @@ size_t ZSTD_insertBtAndFindBestMatch ( size_t bestLength = 0; U32 dummy32; /* to be nullified at the end */ - hashTable[h] = (U32)(ip-base); /* Update Hash Table */ + hashTable[h] = current; /* Update Hash Table */ while (nbCompares-- && (matchIndex > windowLow)) { @@ -1213,7 +1213,7 @@ static U32 ZSTD_insertBt1_extDict(ZSTD_CCtx* zc, const BYTE* const ip, const U32 const BYTE* const dictEnd = dictBase + dictLimit; const BYTE* const prefixStart = base + dictLimit; const BYTE* match = base + matchIndex; - U32 current = (U32)(ip-base); + const U32 current = (U32)(ip-base); const U32 btLow = btMask >= current ? 0 : current - btMask; U32* smallerPtr = bt + 2*(current&btMask); U32* largerPtr = bt + 2*(current&btMask) + 1; @@ -1227,7 +1227,7 @@ static U32 ZSTD_insertBt1_extDict(ZSTD_CCtx* zc, const BYTE* const ip, const U32 return (U32)(rleLength - mls); } - hashTable[h] = (U32)(ip - base); /* Update Hash Table */ + hashTable[h] = current; /* Update Hash Table */ while (nbCompares-- && (matchIndex > windowLow)) { @@ -1318,7 +1318,7 @@ size_t ZSTD_insertBtAndFindBestMatch_extDict ( size_t bestLength = 0; U32 dummy32; /* to be nullified at the end */ - hashTable[h] = (U32)(ip-base); /* Update Hash Table */ + hashTable[h] = current; /* Update Hash Table */ while (nbCompares-- && (matchIndex > windowLow)) { @@ -1726,7 +1726,7 @@ size_t ZSTD_compressBlock_lazy_extDict_generic(ZSTD_CCtx* ctx, /* init */ ZSTD_resetSeqStore(seqStorePtr); - if (((ip-base) - dictLimit) < REPCODE_STARTVALUE) ip += REPCODE_STARTVALUE; + if ((ip - prefixStart) < REPCODE_STARTVALUE) ip += REPCODE_STARTVALUE; /* Match Loop */ while (ip < ilimit) @@ -2008,13 +2008,16 @@ size_t ZSTD_compressContinue (ZSTD_CCtx* zc, } /* preemptive overflow correction */ - if ((zc->base > ip) || (zc->lowLimit > (1<<30) )) + if (zc->lowLimit > (1<<30)) { - U32 correction = zc->lowLimit-1; + U32 btplus = (zc->params.strategy == ZSTD_btlazy2); + U32 contentMask = (1 << (zc->params.contentLog - btplus)) - 1; + U32 newLowLimit = zc->lowLimit & contentMask; /* preserve position % contentSize */ + U32 correction = zc->lowLimit - newLowLimit; ZSTD_reduceIndex(zc, correction); zc->base += correction; zc->dictBase += correction; - zc->lowLimit -= correction; + zc->lowLimit = newLowLimit; zc->dictLimit -= correction; if (zc->nextToUpdate < correction) zc->nextToUpdate = 0; else zc->nextToUpdate -= correction; diff --git a/programs/Makefile b/programs/Makefile index 49061f945..b116fc6b0 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -30,7 +30,7 @@ # fullbench32: Same as fullbench, but forced to compile in 32-bits mode # ########################################################################## -VERSION?= 0.4.3 +VERSION?= 0.4.4 DESTDIR?= PREFIX ?= /usr/local diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 6f23c09a8..ef30f8132 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -70,7 +70,7 @@ **************************************/ #define COMPRESSOR_NAME "zstd command line interface" #ifndef ZSTD_VERSION -# define ZSTD_VERSION "v0.4.2" +# define ZSTD_VERSION "v0.4.4" #endif #define AUTHOR "Yann Collet" #define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), ZSTD_VERSION, AUTHOR, __DATE__