summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* lz4.c: fixed the LZ4_decompress_fast_continue caseAlexey Tourbin2018-04-271-2/+22
| | | | | | | The change is very similar to that of the LZ4_decompress_safe_continue case. The only reason a make this a separate change is to ensure that the fuzzer, after it's been enhanced, can detect the flaw in LZ4_decompress_fast_continue, and that the change indeed fixes the flaw.
* fuzzer.c: enabled ring buffer tests for decompress_fastAlexey Tourbin2018-04-271-40/+81
| | | | | | | | | | | | | Ring buffer tests were performed only with LZ4_decompress_safe_continue, leaving my buggy changes to LZ4_decompress_safe_continue undetected. The tests are now replicated and performed in a similar manner for both LZ4_decompress_safe_continue and LZ4_decompress_safe_continue (except for the small buffer case where only one function can be tested, because part of the dictionary is overwritten with the output). I also updated function names in the messages (changed them to the actual ones). The error was reported for LZ4_decompress_safe(), which I found misleading.
* lz4.c: fixed the LZ4_decompress_safe_continue caseAlexey Tourbin2018-04-262-18/+37
| | | | | | | | | | | | | | | | | | | | | | | | The previous change broke decoding with a ring buffer. That's because I didn't realize that the "double dictionary mode" was possible, i.e. that the decoding routine can look both at the first part of the dictionary passed as prefix and the second part passed via dictStart+dictSize. So this change introduces the LZ4_decompress_safe_doubleDict helper, which handles this "double dictionary" situation. (This is a bit of a misnomer, there is only one dictionary, but I can't think of a better name, and perhaps the designation is not all too bad.) The helper is used only once, in LZ4_decompress_safe_continue, it should be inlined with LZ4_FORCE_O2_GCC_PPC64LE attached to LZ4_decompress_safe_continue. (Also, in the helper functions, I change the dictStart parameter type to "const void*", to avoid a cast when calling helpers. In the helpers, the upcast to "BYTE*" is still required, for compatibility with C++.) So this fixes the case of LZ4_decompress_safe_continue, and I'm surprised by the fact that the fuzzer is now happy and does not detect a similar problem with LZ4_decompress_fast_continue. So before fixing LZ4_decompress_fast_continue, the next logical step is to enhance the fuzzer.
* lz4.c: refactor the decoding routinesAlexey Tourbin2018-04-251-53/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that LZ4_decompress_generic is sometimes instantiated with identical set of parameters, or (what's worse) with a subtly different sets of parameters. For example, LZ4_decompress_fast_withPrefix64k is instantiated as follows: return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB); while the equivalent withPrefix64k call in LZ4_decompress_usingDict_generic passes 0 for the last argument instead of 64 KB. It turns out that there is no difference in this case: if you change 64 KB to 0 KB in LZ4_decompress_fast_withPrefix64k, you get the same binary code. Moreover, because it's been clarified that LZ4_decompress_fast doesn't check match offsets, it is now obvious that both of these fast/withPrefix64k instantiations are simply redundant. Exactly because LZ4_decompress_fast doesn't check offsets, it serves well with any prefixed dictionary. There's a difference, though, with LZ4_decompress_safe_withPrefix64k. It also passes 64 KB as the last argument, and if you change that to 0, as in LZ4_decompress_usingDict_generic, you get a completely different binary code. It seems that passing 0 enables offset checking: const int checkOffset = ((safeDecode) && (dictSize < (int)(64 KB))); However, the resulting code seems to run a bit faster. How come enabling extra checks can make the code run faster? Curiouser and curiouser! This needs extra study. Currently I take the view that the dictSize should be set to non-zero when nothing else will do, i.e. when passing the external dictionary via dictStart. Otherwise, lowPrefix betrays just enough information about the dictionary. * * * Anyway, with this change, I instantiate all the necessary cases as functions with distinctive names, which also take fewer arguments and are therefore less error-prone. I also make the functions non-inline. (The compiler won't inline the functions because they are used more than once. Hence I attach LZ4_FORCE_O2_GCC_PPC64LE to the instances while removing from the callers.) The number of instances is now is reduced from 18 (safe+fast+partial+4*continue+4*prefix+4*dict+2*prefix64+forceExtDict) down to 7 (safe+fast+partial+2*prefix+2*dict). The size of the code is not the only issue here. Separate helper function are much more amenable to profile-guided optimization: it is enough to profile only a few basic functions, while the other less-often used functions, such as LZ4_decompress_*_continue, will benefit automatically. This is the list of LZ4_decompress* functions in liblz4.so, sorted by size. Exported functions are marked with a capital T. $ nm -S lib/liblz4.so |grep -wi T |grep LZ4_decompress |sort -k2 0000000000016260 0000000000000005 T LZ4_decompress_fast_withPrefix64k 0000000000016dc0 0000000000000025 T LZ4_decompress_fast_usingDict 0000000000016d80 0000000000000040 T LZ4_decompress_safe_usingDict 0000000000016d10 000000000000006b T LZ4_decompress_fast_continue 0000000000016c70 000000000000009f T LZ4_decompress_safe_continue 00000000000156c0 000000000000059c T LZ4_decompress_fast 0000000000014a90 00000000000005fa T LZ4_decompress_safe 0000000000015c60 00000000000005fa T LZ4_decompress_safe_withPrefix64k 0000000000002280 00000000000005fa t LZ4_decompress_safe_withSmallPrefix 0000000000015090 000000000000062f T LZ4_decompress_safe_partial 0000000000002880 00000000000008ea t LZ4_decompress_fast_extDict 0000000000016270 0000000000000993 t LZ4_decompress_safe_forceExtDict
* Merge pull request #503 from lz4/l120Yann Collet2018-04-194-66/+132
|\ | | | | minor length reduction of several large lines
| * modified indentation for consistencyYann Collet2018-04-191-17/+33
| |
| * minor length reduction of several large linesYann Collet2018-04-184-65/+115
| |
* | Merge pull request #502 from lhacc1/devYann Collet2018-04-191-0/+4
|\ \ | |/ |/| Wrap likely/unlikely macroses with #ifndef
| * Wrap likely/unlikely macroses with #ifndefDmitrii Rodionov2018-04-181-0/+4
| | | | | | | | | | It prevent redefine error when project using lz4 has its own likely/unlikely macroses.
* | Merge pull request #497 from lz4/lowAddrYann Collet2018-04-187-229/+443
|\ \ | |/ |/| Compatibility with low memory addresses
| * fixed LZ4_compress_fast_extState_fastReset() in 32-bit modeYann Collet2018-04-171-2/+2
| |
| * fix dictDelta setting errorYann Collet2018-04-171-1/+1
| | | | | | | | wrong test
| * fix matchIndex overflowYann Collet2018-04-171-12/+4
| | | | | | | | can happen with dictCtx
| * Merge branch 'dev' into lowAddrYann Collet2018-04-171-2/+9
| |\ | |/ |/|
* | Merge pull request #501 from felixhandte/fix-dict-load-offsetYann Collet2018-04-171-2/+9
|\ \ | | | | | | Always Bump Offset by 64 KB in LZ4_loadDict()
| * | Always Bump Offset by 64 KB in LZ4_loadDict()W. Felix Handte2018-04-171-2/+9
| | | | | | | | | | | | | | | This actually ensures the guarantee referred to in the comment in LZ4_compress_fast_continue().
| | * fixed dictCtx compressionYann Collet2018-04-171-7/+12
| | |
| | * edited a few traces for debuggingYann Collet2018-04-172-10/+10
| | |
| | * fixed minor format warningsYann Collet2018-04-161-3/+3
| | |
| | * fixed fuzzer testsYann Collet2018-04-161-15/+17
| | | | | | | | | | | | which were modified in parallel within branc `dev`
| | * Merge branch 'dev' into lowAddrYann Collet2018-04-164-19/+115
| | |\ | |_|/ |/| |
* | | Merge pull request #499 from felixhandte/lz4-attach-dict-testsYann Collet2018-04-131-2/+99
|\ \ \ | |/ / |/| | Test LZ4_attach_dictionary() and Friends
| * | Further Test that ExtDictCtx Mode Produces the Exact Same OutputW. Felix Handte2018-04-131-2/+21
| | |
| * | Add Tests for LZ4_attach_dictionary and FriendsW. Felix Handte2018-04-131-0/+78
|/ /
* | Merge pull request #496 from lz4/circleciYann Collet2018-04-123-17/+16
|\ \ | | | | | | Reduced LZ4 test time on circle-ci
| * | modified versionsTestYann Collet2018-04-121-1/+1
| | | | | | | | | | | | | | | to use MOREFLAGS rather CPPFLAGS as some older versions of LZ4 overwrite CPPFLAGS environment variable.
| * | allow system-defined CPPFLAGS in /testsYann Collet2018-04-111-1/+1
| | |
| * | reduced test time on circle-ciYann Collet2018-04-113-16/+15
|/ /
| * fixed gcc performance regressionYann Collet2018-04-161-2/+4
| |
| * fixed minor unused variable warningYann Collet2018-04-131-3/+0
| |
| * added comment on variables required after _next_matchYann Collet2018-04-131-0/+8
| |
| * fixed potential ptrdiff_t overflow (32-bits mode)Yann Collet2018-04-131-14/+11
| | | | | | | | Also removed pointer comparison, which should solve #485
| * compatibility with gcc-4.4 string.h versionCyan49732018-04-132-25/+75
| | | | | | | | | | | | | | Someone found it would be a great idea to define there a global variable under the very generic name "index". Cause problem with shadow warnings, so no variable can be named "index" now ... Also : automatically update API manual
| * added sudo rights for low-mem-address testsCyan49732018-04-131-1/+1
| |
| * fixed : counting matches which overlap extDict and prefixtest49732018-04-121-10/+17
| |
| * modified a few traces for debugtest49732018-04-123-7/+9
| |
| * fixed LZ4_compress_fast_extState_fastReset()test49732018-04-111-8/+7
| |
| * Merge branch 'dev' into lowAddrtest49732018-04-113-67/+121
| |\ | |/ |/|
* | Merge pull request #492 from felixhandte/avoid-prepare-in-continueYann Collet2018-04-113-62/+115
|\ \ | | | | | | Several Changes Concerning Table Preparation in LZ4 Fast
| * | Fix Silly Warning (const-ness in declaration has no effect on value types!)W. Felix Handte2018-04-111-1/+1
| | |
| * | Minor FixesW. Felix Handte2018-04-112-11/+13
| | |
| * | Add a LZ4_STATIC_LINKING_ONLY Macro to Guard Experimental APIsW. Felix Handte2018-04-113-0/+4
| | |
| * | Expose dictCtx Functionality in LZ4W. Felix Handte2018-04-113-2/+33
| | |
| * | Rename _extState_noReset -> _extState_fastReset and Edit CommentsW. Felix Handte2018-04-113-27/+41
| | |
| * | Remove Extraneous Assignment (clearedTable == 0)W. Felix Handte2018-04-111-1/+0
| | |
| * | Expose a Faster Stream Reset FunctionW. Felix Handte2018-04-103-28/+37
| | |
| * | Avoid Calling LZ4_prepareTable() in LZ4_compress_fast_continue()W. Felix Handte2018-04-091-20/+14
|/ /
| * fix minor conversion warningtest49732018-04-101-1/+1
| | | | | | | | cast from void not implicit for C++
| * fixed minor conversion warningtest49732018-04-101-1/+2
| | | | | | | | ptr diff -> U32
| * Merge branch 'dev' into lowAddrtest49732018-04-092-24/+23
| |\ | |/ |/|