Repository navigation
Fix signed integer overflow in toStartOfInterval for Millisecond and Microsecond - #101032
Merged
alexey-milovidov merged 4 commits intoMar 29, 2026
Merged
Conversation
…d Microsecond The `scale_multiplier > target_scale` branches in `ToStartOfInterval<Millisecond>` and `ToStartOfInterval<Microsecond>` had no overflow protection for arithmetic on the internal DateTime64 value `t`. When `t` is near `INT64_MAX`, expressions like `t + scale_diff / 2` and `milliseconds * scale_diff` can overflow Int64. Add `addOverflow` and `mulOverflow` checks matching the pattern already used in the `scale_multiplier < target_scale` branches. Found by AST fuzzer in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100378&sha=151861385cd19310e841942ec17ca333b0fe571c&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan_ubsan%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [1eddd40] Summary: ✅ AI ReviewSummaryThis PR adds signed-overflow checks in Findings
Tests
ClickHouse Rules
Final Verdict
|
…al-millisecond-overflow
`CAST(large_int AS DateTime64(6))` clamps the value to the valid DateTime64 range (1900-2299), so the internal value never reaches near INT64_MAX and the overflow check is never exercised. Use `reinterpret` to inject raw internal values directly. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
LLVM Coverage Report
Changed lines: 90.91% (40/44) · Uncovered code |
Member
Author
|
Good. |
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.
The
scale_multiplier > target_scalebranches inToStartOfInterval<Millisecond>andToStartOfInterval<Microsecond>had no overflow protection for arithmetic on the internal DateTime64 valuet. Whentis nearINT64_MAX, expressions liket + scale_diff / 2andmilliseconds * scale_diffcan overflow Int64.Add
addOverflowandmulOverflowchecks matching the pattern already used in thescale_multiplier < target_scalebranches.Found by AST fuzzer in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100378&sha=151861385cd19310e841942ec17ca333b0fe571c&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan_ubsan%29
#100378
Changelog category (leave one):
Version info
26.4.1.374