Commit Graph

348 Commits (f97ca36eab4e3aadf2666a6130d37680a4f6a7d3)

Author SHA1 Message Date
Yann Collet f97ca36eab strengthened conditions for using workplace into fse table space
ensure that the structure layout is as expected.
will trigger an error if it changes in the future.

Another solution would be to use a union,
this would be cleaner and get rid of these static asserts.

However, in order to keep the current code unmodified,
it would be necessary to use an un-named unions.
And apparently, un-named unions are only possible on "recent" compilers (C99+).
2018-09-06 17:54:13 -07:00
Yann Collet 87406548f0 reduced DDict size, by -2KB
corresponding to the removal of workspace
which is needed while building huffman table
and is now either present in DCtx,
or temporarily borrowed from available FSE table space.
2018-09-06 17:07:53 -07:00
Yann Collet 36d6165a2d Makefile: added variable SCANBUILD
so that a different version of scan-build can be selected
2018-08-16 16:44:13 -07:00
Yann Collet 5291d9ac31 fix scope of scan-build tests
exclude zlib code
2018-08-15 17:41:44 -07:00
Yann Collet 42a02ab745 fixed minor warnings issued by scan-build 2018-08-15 14:36:02 -07:00
Yann Collet 6e66bbf5dd fixed several minor issues detected by scan-build
only notable one :
writeNCount() resists better vs invalid distributions
(though it should never happen within zstd anyway)
2018-08-14 16:55:35 -07:00
Yann Collet 31769ce702 error on no forward progress
streaming decoders, such as ZSTD_decompressStream() or ZSTD_decompress_generic(),
may end up making no forward progress,
(aka no byte read from input __and__ no byte written to output),
due to unusual parameters conditions,
such as providing an output buffer already full.

In such case, the caller may be caught in an infinite loop,
calling the streaming decompression function again and again,
without making any progress.

This version detects such situation, and generates an error instead :
ZSTD_error_dstSize_tooSmall when output buffer is full,
ZSTD_error_srcSize_wrong when input buffer is empty.

The detection tolerates a number of attempts before triggering an error,
controlled by ZSTD_NO_FORWARD_PROGRESS_MAX macro constant,
which is set to 16 by default, and can be re-defined at compilation time.
This behavior tolerates potentially existing implementations
where such cases happen sporadically, like once or twice,
which is not dangerous (only infinite loops are),
without generating an error, hence without breaking these implementations.
2018-06-22 17:58:21 -07:00
Yann Collet 166901dc72 reduced POOL_resize() restriction
It's not necessary to ensure that no job is ongoing.
The pool is only expanded, existing threads are preserved.
In case of error, the only option is to return NULL and terminate the thread pool anyway.
2018-06-19 18:07:18 -07:00
Yann Collet d8462ecba2 Merge branch 'dev' into huf_rename 2018-06-14 20:42:10 -04:00
Yann Collet 1adf84ccb7 renamed all HUF_decompress*X4*() functions into *X2
to underline they generate up to 2 symbols per decoding,
in preparation for a future *X3 variant.
2018-06-14 15:17:03 -04:00
Yann Collet a09af5eb6b renamed all HUF_decompress*X2*() functions into *X1
to underline they generate one symbol per decoding operation.

The new naming scheme will make it easier to introduce an *X3 variant.
2018-06-14 15:08:43 -04:00
Yann Collet 7fee966f02 fix dctx initialization within ZSTD_decompress in stack mode
when ZSTD_HEAPMODE=0 (which is not default).

Also : added an associated test (test-fuzzer-stackmode)
run on travis CI

fix #1186
2018-06-14 10:22:24 -04:00
Yann Collet 2108decb41 Fixed a nasty corruption bug
recently introduce into the new dictionary mode.
The bug could be reproduced with this command :
./zstreamtest -v --opaqueapi --no-big-tests -s4092 -t639

error was in function ZSTD_count_2segments() :
the beginning of the 2nd segment corresponds to prefixStart
and not the beginning of the current block (istart == src).
This would result in comparing the wrong byte.
2018-06-01 18:54:34 -07:00
Yann Collet d59cf02df0 decompress: changed error code when input is too large
ZSTD_decompress() can decompress multiple frames sent as a single input.
But the input size must be the exact sum of all compressed frames, no more.

In the case of a mistake on srcSize, being larger than required,
ZSTD_decompress() will try to decompress a new frame after current one, and fail.
As a consequence, it will issue an error code, ERROR(prefix_unknown).

While the error is technically correct
(the decoder could not recognise the header of _next_ frame),
it's confusing, as users will believe that the first header of the first frame is wrong,
which is not the case (it's correct).
It makes it more difficult to understand that the error is in the source size, which is too large.

This patch changes the error code provided in such a scenario.
If (at least) a first frame was successfully decoded,
and then following bytes are garbage values,
the decoder assumes the provided input size is wrong (too large),
and issue the error code ERROR(srcSize_wrong).
2018-05-14 15:32:28 -07:00
Yann Collet 8be984ec45 fixed comments as suggested by @terrelln 2018-03-30 20:09:27 -07:00
Yann Collet e6e848bfe9 added ZSTD_getFrameHeader_advanced()
makes it possible to request frame header from a magicless frame
2018-03-29 17:51:08 -06:00
Yann Collet e0cb8d19c6 fixed legacy test case 2018-03-20 17:48:22 -07:00
Yann Collet 6cda8c932c added test with ZSTD_decompress_generic() + ZSTD_DCtx_refPrefix()
also :
clarified stage condition to accept new parameters,
fixed initializers correspondingly.
2018-03-20 16:16:13 -07:00
Yann Collet 0dadb6b70d implemented ZSTD_DCtx_refPrefix*() 2018-03-20 15:45:56 -07:00
Yann Collet 569b8ba4d9 implemented ZSTD_DCtx_refDDict() 2018-03-20 15:43:49 -07:00
Yann Collet 6873fec658 changed dictMore for dictContentType
which seems clearer to describe what the variable/argument is about.
2018-03-20 15:13:14 -07:00
Yann Collet 31b54b6eea updated ZSTD_initStaticDDict() prototype
can also specify dictContentType.
2018-03-20 14:52:02 -07:00
Yann Collet 353117c5d7 implemented ZSTD_DCtx_loadDictionary*()
this required updating ZSTD_createDDict_advanced()
to accept a dictContentType parameter (raw, full, auto).
2018-03-20 13:40:29 -07:00
Yann Collet fe321f9e2a re-integrate ZSTD_decompressSequencesLong() into zstd_decompress.c
removed zstd_decompress_impl.h
2018-03-09 19:48:06 -08:00
Yann Collet 89a2ebb971 incorporated ZSTD_decompressSequences() into zstd_decompress() 2018-03-09 19:35:57 -08:00
Yann Collet cdb1f1433e incorporated ZSTD_initFseState() inside zstd_decompress.c 2018-03-09 18:16:10 -08:00
Yann Collet a166eae1ba incorporate ZSTD_decodeSequenceLong() within zstd_decompress.c 2018-03-09 18:11:14 -08:00
Yann Collet 17626ba56e restored ZSTD_decodeSequence() into zstd_decompress.c 2018-03-09 18:03:25 -08:00
Yann Collet db147ea620 improved comments
following @terrelln suggestions
2018-03-06 18:15:26 -08:00
Yann Collet 06ca9c7d7c fixed 0-seq blocks in block-decompression mode 2018-03-06 01:50:19 -08:00
Yann Collet 9a91afe6ef long offset mode : new default threshold for 32-bit 2018-03-05 16:41:08 -08:00
Yann Collet 7bd7a3ad43 long offset mode : new default threshold for 64-bits mode 2018-03-05 16:16:49 -08:00
Yann Collet c0393a538f fixed counting long distance weights 2018-03-05 15:12:10 -08:00
Yann Collet cb789d2df8 re-inserted offset evaluation 2018-03-05 13:08:59 -08:00
Yann Collet b91ddf0ae6 Merge branch 'dev' into longOffsetMode 2018-03-05 11:59:54 -08:00
Nick Terrell 6e128d3534 [BMI2] Add comments to the bmi2 variable in the contexts 2018-02-20 14:12:11 -08:00
Nick Terrell 4319132312 [decompress] Support BMI2 2018-02-13 17:00:15 -08:00
Yann Collet 2524cbd847 added code comment on how to generate default tables
as suggested by @terrelln
2018-02-13 10:02:25 -08:00
Yann Collet 71c07966bb added SEQSYMBOL_TABLE_SIZE()
as suggested by @terrelln's comment
2018-02-12 16:52:15 -08:00
Yann Collet 04a3f85ce7 fixed gcc warning on a switch code path 2018-02-09 16:16:27 -08:00
Yann Collet af48f0b62b fix : offset table pointer when using default table 2018-02-09 15:15:46 -08:00
Yann Collet 426944c3e3 fixed strict aliasing issue
tuned threshold
2018-02-09 13:24:11 -08:00
Yann Collet 64ee732694 decide long-offset mode based on offcode statistics
threshold vaguely estimated
2018-02-09 12:33:28 -08:00
Yann Collet 6bfe50ad48 re-enabled ZSTD_decompressSequencesLong() 2018-02-09 09:14:25 -08:00
Yann Collet 1850597eaa pre-calculated default decoding tables 2018-02-09 06:01:02 -08:00
Yann Collet ab75df21ed fixed mono-symbol distribution 2018-02-09 05:12:13 -08:00
Yann Collet 421a2716d8 fixed default fse distributions
but would be better to pre-calculate tables, for speed
2018-02-09 04:50:58 -08:00
Yann Collet 95424409ea addBits and baseline into FSE decoding table
note : unfinished
- need new default tables
- need modify long mode
2018-02-09 04:25:15 -08:00
Yann Collet 0170cf9a7a minor : modified ZSTD_preserveUnsortedMark() to be more vectorization friendly 2018-02-05 11:46:02 -08:00
Yann Collet 94efb1749d faster decoding in 32-bits mode for long offsets (tentative)
On my laptop:
Before:
./zstd32 -b --zstd=wlog=27 silesia.tar enwik8 -S
 3#silesia.tar       : 211984896 ->  66683478 (3.179),  97.6 MB/s , 400.7 MB/s
 3#enwik8            : 100000000 ->  35643153 (2.806),  76.5 MB/s , 303.2 MB/s

After:
./zstd32 -b --zstd=wlog=27 silesia.tar enwik8 -S
 3#silesia.tar       : 211984896 ->  66683478 (3.179),  97.4 MB/s , 435.0 MB/s
 3#enwik8            : 100000000 ->  35643153 (2.806),  76.2 MB/s , 338.1 MB/s

Mileage vary, depending on file, and cpu type.
But a generic rule is : x86 benefits less from "long-offset mode" than x64,
maybe due to register pressure.
On "entropy", long-mode is _never_ a win for x86.
On my laptop though, it may, depending on file and compression level
(enwik8 benefits more from "long-mode" than silesia).
2018-02-04 01:49:31 -08:00