You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Persisted dictionary pages may contain invalid signed int32_t dictionary codes. BinaryDictPageDecoder previously allowed negative or out-of-range codes to reach downstream dictionary handling without enforcing:
0 <= code < dictionary_size
This could expose invalid dictionary state to downstream consumers instead of returning a corruption error at the storage decoding boundary.
This PR validates decoded dictionary codes before they become caller-visible:
next_batch() validates the complete decoded batch before inserting normal dictionary output, resolving only_read_offsets, updating *n, or advancing the decoder cursor.
read_by_rowids() gathers and validates all selected codes before producing caller-visible output or updating *n.
Negative codes and codes greater than or equal to the dictionary size now return Status::Corruption.
The validation uses a signedness-safe bounds check.
Valid dictionary-code behavior remains unchanged.
The regression test covers:
negative dictionary code (-1);
dictionary code equal to dictionary_size;
next_batch();
read_by_rowids();
normal dictionary output;
only_read_offsets;
unchanged destination/count/cursor state when corruption is detected;
valid-input behavior for all covered paths.
The regression test was verified RED → GREEN: it fails without the production validation and passes after the validation is restored.
clang-tidy was attempted but was inconclusive due to pre-existing/toolchain diagnostics; no new diagnostic was observed on the newly added validation or regression-test lines.
The validation adds one additional sequential O(n) pass over decoded dictionary codes for valid data. No directly applicable BinaryDictPageDecoder benchmark is currently available, so the performance impact has not been quantitatively established.
This addresses a matching dictionary-decoder robustness issue found while investigating the reported crash. The original production segment was not available for exact reproduction, so this PR does not claim reproduction of the exact production crash.
Release note
None
Check List (For Author)
Test
Regression test
Unit Test
Manual test (add detailed scripts or steps below)
No need to test or manual test. Explain why:
This is a refactor/code format and no logic has been changed.
Previous test can cover this change.
No code files have been changed.
Other reason
Behavior changed:
No.
Yes. Invalid persisted dictionary codes are now rejected with Status::Corruption at the decoder boundary instead of being propagated to downstream dictionary handling.
Hi @yiguolei, could you please take a look when convenient?
All functional/build/regression TeamCity checks are now green. The only remaining failed TeamCity check is check_coverage, which has failed twice during CI setup before coverage processing.
Both runs failed because the CI runner could not resolve either LDB toolchain OSS hostname, on two different TeamCity agents. llvm-profdata / llvm-cov were never reached, so this does not appear to be a coverage-threshold failure.
The remaining GitHub workflows also require maintainer approval.
Thanks!
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
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.
What problem does this PR solve?
Issue Number: #63609
Related PR: N/A
Problem Summary:
Persisted dictionary pages may contain invalid signed
int32_tdictionary codes.BinaryDictPageDecoderpreviously allowed negative or out-of-range codes to reach downstream dictionary handling without enforcing:This could expose invalid dictionary state to downstream consumers instead of returning a corruption error at the storage decoding boundary.
This PR validates decoded dictionary codes before they become caller-visible:
next_batch()validates the complete decoded batch before inserting normal dictionary output, resolvingonly_read_offsets, updating*n, or advancing the decoder cursor.read_by_rowids()gathers and validates all selected codes before producing caller-visible output or updating*n.Status::Corruption.The regression test covers:
-1);dictionary_size;next_batch();read_by_rowids();only_read_offsets;The regression test was verified RED → GREEN: it fails without the production validation and passes after the validation is restored.
ASAN unit test:
BUILD_TYPE_UT=ASAN ./run-be-ut.sh --run -j2 \ --filter='BinaryDictPageTest.RejectInvalidDictionaryCodes'Result: PASS, 1/1.
Additional checks:
build-support/clang-format.sh: PASSbuild-support/check-format.sh: PASSgit diff --check origin/master...HEAD: PASSThe validation adds one additional sequential O(n) pass over decoded dictionary codes for valid data. No directly applicable
BinaryDictPageDecoderbenchmark is currently available, so the performance impact has not been quantitatively established.This addresses a matching dictionary-decoder robustness issue found while investigating the reported crash. The original production segment was not available for exact reproduction, so this PR does not claim reproduction of the exact production crash.
Release note
None
Check List (For Author)
Test
Regression test
Unit Test
Manual test (add detailed scripts or steps below)
No need to test or manual test. Explain why:
Behavior changed:
Status::Corruptionat the decoder boundary instead of being propagated to downstream dictionary handling.Does this need documentation?
Check List (For Reviewer who merge this PR)