fix(compress): restore C fallback for unsupported CCtx strategies
ZSTD_compressCCtx was selecting the Rust frame path for every compression level. For source sizes that resolve to lazy or optimal strategies, that path fell through to fast matching and could produce a different frame, including the CCtx reuse regression caught by fuzzer test 56. Query the source-size-dependent C parameters before preparing the context. Keep fast and double-fast strategies on the existing Rust path, while routing all other strategies through ZSTD_compress_usingDict with no dictionary so the original simple API initializes requested parameters and C match state. Test Plan: - `make -B -C tests -j2 fuzzer` -- passed - `./tests/fuzzer -s4560 -t56 -i56 -v` -- passed - `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression` -- 253 passed - required clippy normal, benches, and tests checks -- passed - `cargo +nightly fmt --manifest-path rust/Cargo.toml` -- passed - `git diff --check` and `git diff --cached --check` -- passed
This commit is contained in:
@@ -50,6 +50,7 @@ size_t ZSTD_rust_resetCCtxForSimpleCompression(void* cctx);
|
||||
size_t ZSTD_rust_prepareCCtxForSimpleCompression(void* cctx,
|
||||
size_t srcSize,
|
||||
int compressionLevel);
|
||||
int ZSTD_rust_compressCCtxStrategy(size_t srcSize, int compressionLevel);
|
||||
size_t ZSTD_rust_resetCCtxForSimpleCompressionSession(void* cctx);
|
||||
void ZSTD_rust_markSimpleCompression2Complete(void* cctx);
|
||||
size_t ZSTD_compress2_c(ZSTD_CCtx* cctx,
|
||||
@@ -3837,6 +3838,13 @@ size_t ZSTD_compress_usingDict(ZSTD_CCtx* cctx,
|
||||
|
||||
/* The Rust simple API still needs the C-owned context reset, but does not
|
||||
* cross the private context layout. */
|
||||
int ZSTD_rust_compressCCtxStrategy(size_t srcSize, int compressionLevel)
|
||||
{
|
||||
ZSTD_parameters const params = ZSTD_getParams_internal(
|
||||
compressionLevel, srcSize, 0, ZSTD_cpm_noAttachDict);
|
||||
return (int)params.cParams.strategy;
|
||||
}
|
||||
|
||||
size_t ZSTD_rust_resetCCtxForSimpleCompression(void* cctx)
|
||||
{
|
||||
return ZSTD_CCtx_reset((ZSTD_CCtx*)cctx, ZSTD_reset_session_and_parameters);
|
||||
|
||||
Reference in New Issue
Block a user