Conversation
|
Looks like something is not quite happy with how DDS adjusts its parameters and the increase and/or decrease of |
|
Also, local testing reveals that this assert is also failing Line 531 in 3eb3845 |
cc @felixhandte |
|
So I think the two changes should be the correct fix. If I'm not mistaken, the original seems to indicate that there was never any actual adjustment of the DDSS |
lib/compress/zstd_compress.c
Outdated
| static ZSTD_compressionParameters ZSTD_dedicatedDictSearch_getCParams(int const compressionLevel, size_t const dictSize) | ||
| { | ||
| ZSTD_compressionParameters cParams = ZSTD_getCParams_internal(compressionLevel, 0, dictSize, ZSTD_cpm_createCDict); | ||
| ZSTD_compressionParameters cParams = ZSTD_getCParams_internal(compressionLevel, ZSTD_CONTENTSIZE_UNKNOWN, dictSize, ZSTD_cpm_createCDict); |
lib/compress/zstd_compress.c
Outdated
| cParams = ZSTD_dedicatedDictSearch_getCParams( | ||
| cctxParams.compressionLevel, dictSize); | ||
| ZSTD_overrideCParams(&cParams, &cctxParams.cParams); | ||
| ZSTD_overrideCParams(&cctxParams.cParams, &cParams); |
There was a problem hiding this comment.
Hm. The original may be mistaken, but I don't think this is a correct fix.
This call is of the form ZSTD_overrideCParams(dst, src). This had been part of a multi-step resolution of params into the local cParams. The intent here is to first get the default cparams for the level, and then override those params with any explicit cparams that were set in the cctxparams by the user. These resolved params are then fed back into the cctxparams (on :4812) and passed down the stack.
With this new version, we will just ignore any explicit cparams set by the user. Which might well fix the assertion failure you're seeing, if the clevel derived params are all safe, but the fuzzer is setting bad cparams that aren't getting caught and rejected.
But then the correct fix would be to correctly validate the cparam set for ddss.
There was a problem hiding this comment.
This detailed explanation is probably worth becoming a code comment
There was a problem hiding this comment.
That makes sense: so the idea here is that if hLog is explicitly set, DDS will not override that by adding 2 to it.
But the actual issue here is that if we set hLog = 7 explicitly, DDS will not override. But later on, ZSTD_dedicatedDictSearch_revertCParams() is called anyways, subtracting 2 from the hLog, making us end up with an invalid hLog of 5 in ZSTD_resetCCtx_byAttachingCDict() here:
zstd/lib/compress/zstd_compress.c
Lines 1996 to 2016 in 3eb3845
At this point in the code, is it even possible to tell whether or not the hLog is an hLog that was explicitly set or an hLog that was adjusted because DDS is available? Ideally, we'd want to be able to detect the latter case, and only subtract from hLog then.
Maybe we can just call ZSTD_clampCParams() on the ZSTD_adjustCParams_internal() call right after, but that would still mean that the hLog could still get reduced when it shouldn't be.
There was a problem hiding this comment.
Why would the interpretation of hlog by DDS be different, depending on this parameter being automatically determined or explicitly set ? The way hlog is set should not matter.
Moreover, the interpretation of hlog should remain local.
If DDS considers that a hlog==7 will actually be interpreted as 5 for its own use, that's fine,
but this "interpreted value" should not be confused with the parameter hlog.
As a consequence, this interpretation should remain private within DDS, and in no way impact any other part of the system, not even indirectly.
|
I've pushed @felixhandte's fix for all the assert issues onto this PR in the latest commit, it should fix the issue. |
|
Thanks @senhuang42, DDS coverage looks good now! |
DDS wasn't getting fuzzed, this adds it (back?) to OSS-Fuzz