]> git.ipfire.org Git - thirdparty/zstd.git/commit
cli: fixed wrong initialization in MT mode
authorYann Collet <cyan@fb.com>
Sat, 30 Sep 2017 05:14:37 +0000 (22:14 -0700)
committerYann Collet <cyan@fb.com>
Sat, 30 Sep 2017 05:14:37 +0000 (22:14 -0700)
commit8afb151c9b0ddb102cee7637b22552fec1d6acb0
treeee94bf09c72efe75084989b4e8dc2c2f5686a92a
parentfbd5ab70272095255948255368ac4f2f64aca780
cli: fixed wrong initialization in MT mode

It's not good to mix old and new API
ZSTD_resetCStream() doesn't just set pledgedSrcSize :
it also sets the CCtx for a single thread compression.

Problem is, when 2+ threads are defined in cctx->requestedParams,
ZSTD_compress_generic() will want to start MT compression,
since initialization is supposed to have already happened (thanks to ZSTD_resetCStream())
except that the underlying ZSTDMT_CCtx* object is not created,
resulting in a segfault.

This is an invalid construction
(correct one is to use ZSTD_CCtx_setPledgedSrcSize()).
I haven't found a nice way to mitigate this impact if someone makes the same mistake.

At some point, removing the old API to keep only the new API within fileio.c will limit these risks.
lib/compress/zstd_compress.c
programs/fileio.c