Repository navigation
Fix signed integer overflow in parseDateTimeBestEffort - #100368
Conversation
…art parsing When parsing unix timestamps with fractional parts (e.g. `1234567890.12345678901234567`), the fractional digit count was not clamped to `std::numeric_limits<Int64>::digits10`, causing signed integer overflow in `readDecimalNumber`. This was already fixed for one call site (the general fractional parsing path) but two other call sites (unix timestamp with 9 and 10 digits) were missing the same protection. Apply the same clamping pattern to the remaining call sites. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=d370916dc6c37021dcc9c7dd6f327cfc8b1198fd&name_0=MasterCI&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [9212d31] Summary: ❌
AI ReviewSummaryThis PR adds a focused stateless regression test for the signed-overflow scenario in ClickHouse Rules
Final Verdict
|
|
Missing test. |
Test that `parseDateTime64BestEffort` handles fractional parts with 18-19 digits without signed integer overflow in `readDecimalNumber`. These inputs previously triggered UBSan errors because the fractional digit count was not clamped to `std::numeric_limits<Int64>::digits10`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
| -- https://github.com/ClickHouse/ClickHouse/pull/100368 | ||
|
|
||
| -- 10-digit unix timestamp with 19-digit fractional part (exceeds Int64::digits10 = 18) | ||
| SELECT parseDateTime64BestEffort('1234567890.1234567890123456789'); |
There was a problem hiding this comment.
Bugfix validation reports Failed to reproduce the bug.
The 19-digit fractional literals here start with 1 (1234567890123456789), and that value still fits in Int64, so old code can parse it without triggering signed overflow. Please use a 19-digit fractional value that exceeds Int64 (for example, 9999999999999999999) so the old path reliably hits the overflow and the bugfix validation test actually validates the fix.
The test output depends on timezone, but `session_timezone` is randomized in CI. Pin it to UTC so the reference file is stable. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…mezone Use `9999999999999999999` (19 nines) as the fractional part instead of `1234567890123456789`, which fits in `Int64` and does not trigger the overflow. Also pass the timezone explicitly as the third argument to `parseDateTime64BestEffort` instead of using `SET session_timezone` to avoid environment-dependent failures. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… values The test reference was generated on a CET machine, producing timestamps 1 hour ahead of UTC. The Fast test CI runner uses UTC, causing a mismatch. Fix by setting `session_timezone = 'UTC'` and updating the reference to the correct UTC values. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: 100.00% (20/20) · Uncovered code |
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The bugfix validation runs under debug, not ubsan. However, this is not a bug fix. I will change the category. |
When parsing unix timestamps with fractional parts (e.g.
1234567890.12345678901234567), the fractional digit count was not clamped tostd::numeric_limits<Int64>::digits10, causing signed integer overflow inreadDecimalNumber. This was already fixed for one call site (the general fractional parsing path at line 532) but two other call sites (unix timestamps with 9 and 10 digits) were missing the same protection.The overflow was caught by UBSan in the
FunctionsStress.stressunit test:CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=d370916dc6c37021dcc9c7dd6f327cfc8b1198fd&name_0=MasterCI&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix signed integer overflow when parsing fractional seconds in
parseDateTimeBestEffortwith very long fractional parts.Documentation entry for user-facing changes
Version info
26.4.1.759