Repository navigation
Fix signed Int64 overflow when computing fraction in roundTimeConstant - #129979
zaidrain06 wants to merge 2 commits into
Conversation
|
|
|
Workflow [PR], commit [f7aee2e] Summary: ✅
AI ReviewSummaryThe PR fixes signed Missing context / blind spots
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, 8 s compile time in total, 7 of them have a recent master baseline. |
Closes: #129976
Related: #129017
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix signed
Int64overflow when computingfractioninroundTimeConstant(QueryConditionCacheTimeConditions.cpp) forDateTime64(4..9)values nearINT64_MIN.Details
In
roundTimeConstant(src/Interpreters/Cache/QueryConditionCacheTimeConditions.cpp:179),whole_seconds * multiplieroverflows signedInt64whenticksis within one second aboveINT64_MIN(e.g.INT64_MIN + 1) andscaleis in4..9, becausefloor(ticks / multiplier)is-9223372037for scale 9 (-9223372037 * 10^9 < INT64_MIN), which passes themax_reasonable_seconds(1e15) check at line 145.Computing
fractiondirectly viaticks % multiplier(and addingmultiplierwhen negative) avoids the intermediatewhole_seconds * multiplierproduct and eliminates the UBSan signed integer overflow. Added unit test coverageDateTime64NearInt64MinDoesNotOverflowFractioninsrc/Interpreters/tests/gtest_query_condition_cache_time_conditions.cppcovering scales4,6, and9for bothWeakenandStrengthen.Workflow [PR]
Sync PR [sync-upstream/pr/129979]