Repository navigation
Fix UBSan reports in master: unsigned wraparound in offsets[row - 1] of the JSON conversion - #133910
Conversation
`FunctionsConversion.cpp` read `offsets[row - 1]` with `row == 0` in six places added in #107866. `row` is a `size_t`, so the index wraps around before it reaches the `ssize_t` parameter of `PODArray::operator[]`, and the `unsigned-integer-overflow` check of UBSan, enabled in #120906, reports it and stops the server: src/Functions/FunctionsConversion.cpp:2929:73: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') #0 newLeafTypedPathsNeedFormatParse src/Functions/FunctionsConversion.cpp:2929:73 #1 DB::detail::(anonymous namespace)::convertObjectColumns src/Functions/FunctionsConversion.cpp:3343:9 Since the merge of that pull request, the `asan_ubsan` stateless tests on master fail with `UndefinedBehaviorSanitizer: undefined behavior (STID: 0993-9a84)` and `Server died`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=e903e8848f033e59d209c21e5258e617157ba884&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29 Use the signed form `offsets[static_cast<ssize_t>(row) - 1]`, as the rest of the code does. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Workflow [PR], commit [4a2743a] Summary: ✅
AI ReviewSummaryPR #133910 fixes six unsigned offset underflows in Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 46 s compile time in total, 7 of them have a recent master baseline. |
Related: #107866
Related: #120906
FunctionsConversion.cppreadsoffsets[row - 1]withrow == 0in six places added in #107866.rowis asize_t, so the index wraps around before it reaches thessize_tparameter ofPODArray::operator[], and theunsigned-integer-overflowcheck of UBSan, enabled in #120906 on the same day, reports it and stops the server:Since the merge of #107866 (
e903e8848f03, 2026-11-23), theasan_ubsanstateless tests on master fail withUndefinedBehaviorSanitizer: undefined behavior (STID: 0993-9a84)andServer died: 23 failures on 11 master commits within the first 2.5 hours, and the same in pull requests that merged or are tested with the new master. The first report:https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=e903e8848f033e59d209c21e5258e617157ba884&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
The fix uses the signed form
offsets[static_cast<ssize_t>(row) - 1], as the rest of the code does. The existing tests of theJSONconversion cover it under UBSan. I did not find an open issue for this report.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/133910]
Version info
26.12.1.345-master(included in26.12and later)