Repository navigation
Fix UBSan out-of-bounds pointer arithmetic in compareSubstrings - #106733
Conversation
`compareSubstrings` formed the per-row `str1` / `str2` pointers (adding `str1_offset` / `str2_offset`) unconditionally, before the `isOverflowComparison` bounds check, in `executeStringString` and `executeFixedStringString`. When an offset argument was out of range, the pointer arithmetic itself went out of bounds, which `UndefinedBehaviorSanitizer` flags as `addition of unsigned offset ... overflowed`, even though the pointer was only dereferenced inside the (in-bounds) overflow-check branch. Form the pointers only after the overflow check passes, matching the already-safe pattern in the `*Const` variants. Found by the AST fuzzer, e.g. `SELECT compareSubstrings(s1, s2, 4, 4, 1048577)` over `FixedString(3)` columns. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [b2b8c8c] Summary: ✅
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
…aster Co-Authored-By: Claude Fable 5 <[email protected]>
|
Merged The sole CI failure, @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106733&sha=2d7b1a2c5c6096b6036e2071c9fca166a05cfd86&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. |
|
@alexey-milovidov fix is up in a separate PR: #107054. Confirmed your diagnosis. The PR pins |
|
@alexey-milovidov investigated. Your diagnosis was correct, and the root-cause global fix is already merged.
This is a single-lane problem. Code 241 Root cause and fix: #106962 by Algunenano (merged 2026-06-11), tagging My per-test PR #107054 ( |
|
CI triage for the previous head (
Since both fixes are on |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 18/18 (100.00%) | Lost baseline coverage: none · Uncovered code |
compareSubstringsformed the per-rowstr1/str2pointers (addingstr1_offset/str2_offset) unconditionally, before theisOverflowComparisonbounds check, inexecuteStringStringandexecuteFixedStringString. When an offset argument is out of range, the pointer arithmetic itself goes out of bounds, whichUndefinedBehaviorSanitizerflags asaddition of unsigned offset ... overflowed, even though the pointer is only dereferenced inside the (in-bounds) overflow-check branch.The pointers are now formed only after the overflow check passes, matching the already-safe pattern in the
*Constvariants. The computation of the pointers and adjusted lengths is unchanged, so results are identical.Found by the AST fuzzer on PR #105129, e.g.:
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105129&sha=163f7a6cb74c136b71b84adf20bce9a29e9e5dc3&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan_ubsan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.6.1.724