Repository navigation
Prevent ZstandardDictionary.Train crashes for small sample sets - #135274
Merged
Merged
Conversation
Guard the native trainer's 75% sample prefix against size underflow while preserving existing IOException mapping and argument validation. Add crash regressions and minimum-size boundary coverage. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
wfurt
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ZstandardDictionary.Traincan crash the process when the first 75% of samples contain fewer than 8 bytes. The bundled zstd trainer validates the total corpus size, but computes its working size from that smaller training subset, allowing unsigned underflow.Add a temporary managed guard that sums the training prefix during the existing sample-length validation and copy. Reject insufficient training data through the existing
srcSize_wrongerror mapping toIOException, preserving argument-validation order. Vendored zstd remains unchanged; the workaround can be removed once the bundled version includes a fix for facebook/zstd#4827.Regression coverage includes the reported crash, different sample counts and prefix sizes, successful 8-byte and 9-byte boundaries, and argument-validation precedence.
Validation
Executed on Windows x64 using a dedicated
substpath:.\build.cmd clr+libs -rc release: passed..\.dotnet\dotnet.exe build src\libraries\System.IO.Compression\tests\System.IO.Compression.Tests.csproj /t:Test /p:XunitMethodName=System.IO.Compression.ZstandardDictionaryTests.Train_InsufficientTrainingBytes_ThrowsIOException: reproduced the access violation before the fix (0xC0000005).U:\.dotnet\dotnet.exe buildfromsrc\libraries\System.IO.Compression: passed.U:\.dotnet\dotnet.exe build tests\System.IO.Compression.Tests.csproj /t:Test /p:XunitClassName=System.IO.Compression.ZstandardDictionaryTestsfrom that directory: passed, 17 tests..\.dotnet\dotnet.exe build src\libraries\System.IO.Compression\tests\System.IO.Compression.Tests.csproj /t:Test: passed on the final patch, 2,999 tests with zero failures.Other platforms and outer-loop tests were not run.
Resolves #135264
Note
This pull request description and code changes were generated with GitHub Copilot.