Repository navigation
Add more checks for mark access for better diagnostics - #100115
Merged
Merged
Conversation
…ergeTreeMarksGetter` A segfault occurs in `readBits` when reading marks from a compact part during mutation execution. The crash happens because `MarksInCompressedFile::get` is called with an out-of-bounds index, causing `lookUpMark` to read garbage from the `blocks` array, which produces an invalid bit offset that accesses unmapped memory. This is likely caused by a race condition involving the mark cache where cached marks become inconsistent with the reader's expectations. The fix adds bounds checking at multiple levels: - `MarksInCompressedFile::get`: throws exception instead of segfaulting when `idx >= num_marks` - `MergeTreeMarksGetter` constructor: validates that marks count is consistent with `num_columns_in_mark` - `MergeTreeMarksGetter::getMark`: upgrades `column_index` bounds check from debug-only to always-on CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=f79634708dca0c8dc4bcaaa7f9bbd30ac4c23c6e&name_0=MasterCI&name_1=BuzzHouse%20%28amd_ubsan%29 Closes: #98579 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [103a37f] Summary: ✅ AI ReviewSummaryThis PR hardens mark access by adding runtime bounds checks in ClickHouse Rules
Final Verdict
|
…c = 2` setting The `SYSTEM SYNC MUTATIONS` command does not exist in ClickHouse. Use `mutations_sync = 2` setting on the ALTER statement instead. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 65.22% (15/23, 5 noise lines excluded) |
alexey-milovidov
left a comment
Member
Author
There was a problem hiding this comment.
Good, no changes in behavior, test-only change.
1 task
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A segfault occurs in
readBitswhen reading marks from a compact part during mutation execution. The crash happens becauseMarksInCompressedFile::getis called with an out-of-bounds index, causinglookUpMarkto read garbage from theblocksarray, which produces an invalid bit offset that accesses unmapped memory.This is likely caused by a race condition involving the mark cache where cached marks become inconsistent with the reader's expectations.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=f79634708dca0c8dc4bcaaa7f9bbd30ac4c23c6e&name_0=MasterCI&name_1=BuzzHouse%20%28amd_ubsan%29
The fix adds bounds checking at multiple levels:
MarksInCompressedFile::get: throws exception instead of segfaulting whenidx >= num_marksMergeTreeMarksGetterconstructor: validates that marks count is consistent withnum_columns_in_markMergeTreeMarksGetter::getMark: upgradescolumn_indexbounds check from debug-only to always-onCloses #98579
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add bounds checking for mark access in
MarksInCompressedFileandMergeTreeMarksGetterto prevent segfault when reading compact parts.Documentation entry for user-facing changes
Version info
26.4.1.160