Skip to content

Fix use-of-uninitialized-value in formatDateTime#96133

Merged
alexey-milovidov merged 2 commits intomasterfrom
fix-formatdatetime-msan
Feb 6, 2026
Merged

Fix use-of-uninitialized-value in formatDateTime#96133
alexey-milovidov merged 2 commits intomasterfrom
fix-formatdatetime-msan

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

mysqlFractionalSecondScaleNumDigits and mysqlFractionalSecondSingleZero used dest[i-1] += fractional_second % 10 which reads the destination byte before writing. When the output buffer is not pre-filled with the template (variable-width formatters path, e.g. format string contains %M), this reads uninitialized memory.

Also fix jodaFractionOfSecond where toString(fractional_second) does not preserve leading zeros (e.g. fractional_second=5, scale=3 gives "5" instead of "005"), leaving the buffer partially uninitialized.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=172a57f2ad219399818d551a89e2d32d62f88ccf&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix use-of-uninitialized-value in formatDateTime with non-fixed-width formatters, such as MySQL and JODA-style.

alexey-milovidov and others added 2 commits February 6, 2026 02:11
`mysqlFractionalSecondScaleNumDigits` and `mysqlFractionalSecondSingleZero`
used `dest[i-1] += fractional_second % 10` which reads the destination byte
before writing. When the output buffer is not pre-filled with the template
(variable-width formatters path, e.g. format string contains `%M`), this
reads uninitialized memory.

Also fix `jodaFractionOfSecond` where `toString(fractional_second)` does not
preserve leading zeros (e.g. fractional_second=5, scale=3 gives "5" instead
of "005"), leaving the buffer partially uninitialized.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=172a57f2ad219399818d551a89e2d32d62f88ccf&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 6, 2026

Workflow [PR], commit [7fe6c77]

Summary:

job_name test_name status info comment
Stress test (amd_ubsan) failure
Logical error: Block structure mismatch in A stream: different number of columns: (STID: 0993-38e6) FAIL cidb, issue
AST fuzzer (amd_debug) failure
Logical error: Sort order of blocks violated for column number A, left: B, right: C. Chunk D, rows read E.F (STID: 3413-350b) FAIL cidb

@clickhouse-gh clickhouse-gh bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Feb 6, 2026
@alexey-milovidov alexey-milovidov merged commit 473f367 into master Feb 6, 2026
129 of 133 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-formatdatetime-msan branch February 6, 2026 04:54
@alexey-milovidov alexey-milovidov self-assigned this Feb 6, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 6, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Feb 6, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Feb 6, 2026
clickhouse-gh bot added a commit that referenced this pull request Feb 6, 2026
Backport #96133 to 26.1: Fix use-of-uninitialized-value in `formatDateTime`
clickhouse-gh bot added a commit that referenced this pull request Feb 6, 2026
Backport #96133 to 25.11: Fix use-of-uninitialized-value in `formatDateTime`
alexey-milovidov added a commit that referenced this pull request Feb 6, 2026
Backport #96133 to 25.12: Fix use-of-uninitialized-value in `formatDateTime`
alexey-milovidov added a commit that referenced this pull request Mar 17, 2026
Backport #96133 to 25.8: Fix use-of-uninitialized-value in `formatDateTime`
alexey-milovidov added a commit that referenced this pull request Mar 17, 2026
Backport #96133 to 25.3: Fix use-of-uninitialized-value in `formatDateTime`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants