Skip to content

Fix the nightly libFuzzer OOM and timeout - #118286

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-libfuzzer-nightly-datelut-oom
Sep 6, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-libfuzzer-nightly-datelut-oom

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Fixes the two failures in the nightly libFuzzer run at
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=8d8dd308b73c4bb8ef921f0b01f6806656054872&name_0=NightlyFuzzers&name_1=libFuzzer%20tests

Related: #107459

data_type_deserialization_fuzzer ran out of memory

out-of-memory (used: 8235Mb; limit: 8192Mb), with 5.5 GB of live heap in
DateLUT::getImplementation. This is server behaviour, not a fuzzer artifact.

cctz synthesizes a zone for every name of the form Fixed/UTC±HH:MM:SS without
consulting the time zone database, and accepts any offset up to 24 hours - 172801 distinct
names. Each name that gets loaded permanently costs ~4.6 MiB in the DateLUT cache, and
that cache never evicts anything because callers keep bare const DateLUTImpl & references
into it. Measured on master:

distinct names used max RSS
1 187 MB
180 989 MB
600 2964 MB

So toDateTime(x, '<name>'), the session_timezone setting, binary type decoding and the
time zone of an Arrow or ORC timestamp column could all make the server allocate memory that
it never gives back.

These names cannot simply be rejected: reading an Arrow or ORC timestamp column with a
fixed-offset time zone deliberately produces them (03926_arrow_fixed_offset_timezone).
Instead, only the offsets that a time zone can actually have are accepted - a whole number
of quarters of an hour, no further from UTC than 14 hours. That covers every offset in the
time zone database (the last one that was not a multiple of 15 minutes ended in 1972) and
leaves 113 such names, which bounds the cache. DateLUTImpl::Values::OffsetChangeFactor
already assumes the same granularity for the offset changes within a zone.

SettingFieldTimezone::validateTimezone goes through the same predicate, so a
session_timezone value cannot be accepted and then fail on every query.

This does not fix #107459 - enumerating the 597 names of the time zone database still
accumulates ~2.9 GB - it stops that accumulation from being unbounded.

select_parser_fuzzer hit its per-input timeout

libFuzzer: timeout after 60 seconds, while the target was still replaying its own corpus
(19701 of the 19686 corpus files, at 9 exec/s).

Nothing is wrong with the parser: the 334 KB input it timed out on parses in 0.28 s of CPU
in a release build. The target's seed corpus is generated from tests/queries, whose largest
file is ~380 KB, and with no explicit max_len libFuzzer sizes every input after that file
(lim: 381493), so it both replays and mutates inputs that a sanitizer build cannot parse
within 60 seconds. Capped at 65536, the same cap create_parser_fuzzer already uses.

The report's statistics were nonsense

replaying the initial corpus took 19701 of 140 executed inputs (14072%), leaving -19561 mutations

parse_libfuzzer_output split each line before testing it, which strips indentation, so the
frames of a sanitizer stack trace ( #140 0xaada2314ee40 in DB::ParserCollectionOfLiterals...)
were taken for libFuzzer progress lines, and the depth of the last stack frame was reported as
the number of executed inputs. Both failing targets reported a stack depth. Anchoring the
progress line at the start of the line and requiring its event to be a word, the same two logs
now parse as:

target before after
select_parser_fuzzer executed 140 inputs executed 34930 inputs, exec/s: 8, cov: 16848, ft: 82000, corp: 8468/16Mb, rss: 1759Mb
data_type_deserialization_fuzzer executed 28 inputs executed 665212 inputs, exec/s: 88, cov: 25383, ft: 120615, corp: 15862/6631Kb, rss: 8235Mb

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix unbounded memory growth from time zone names of the form Fixed/UTC±HH:MM:SS. Every distinct name permanently cost ~4.6 MiB that the server never gave back, and 172801 of them were accepted. Only offsets that a time zone can have are accepted now: a whole number of quarters of an hour, no further from UTC than 14 hours.


Workflow [PR]
Sync PR [sync-upstream/pr/118286]

Version info

  • Merged into: 26.9.1.825 (included in 26.9 and later)

The `NightlyFuzzers` run at 8d8dd30 failed with
two findings.

`data_type_deserialization_fuzzer` ran out of memory (used 8235 Mb, limit 8192 Mb)
with 5.5 GB of live heap in `DateLUT::getImplementation`. `cctz` synthesizes a zone
for every name of the form `Fixed/UTC±HH:MM:SS` without consulting the time zone
database, and accepts any offset up to 24 hours, which is 172801 distinct names.
Every name that gets loaded permanently costs ~4.6 MiB in the `DateLUT` cache, and
that cache never evicts anything because callers keep bare references into it, so
untrusted input could make the server allocate memory that it never gives back:
1 name costs 187 MB of RSS, 180 names cost 989 MB, 600 names cost 2964 MB.

Accept only the offsets a time zone can actually have: a whole number of quarters
of an hour, no further from UTC than 14 hours. That covers every offset in the time
zone database - the last one that was not a multiple of 15 minutes ended in 1972 -
and leaves 113 such names, which bounds the cache. `Values::OffsetChangeFactor`
already assumes the same granularity for the offset changes within a zone. The
`session_timezone` setting validates through the same predicate, so a value cannot
be accepted and then fail on every query.

`select_parser_fuzzer` hit its 60 second per-input timeout while still replaying its
own corpus. Its seed corpus is generated from `tests/queries`, whose largest file is
~380 KB, and without an explicit `max_len` libFuzzer sizes every input after that
file. The 334 KB input it timed out on parses in 0.28 s of CPU in a release build,
so nothing is wrong with the parser - a query that long just cannot be parsed within
60 seconds by a sanitizer build. Cap the input length at 65536, the same cap
`create_parser_fuzzer` already uses.

The statistics the report printed for both targets were nonsense - "replaying the
initial corpus took 19701 of 140 executed inputs (14072%), leaving -19561 mutations".
`parse_libfuzzer_output` split each line before testing it, which strips indentation,
so the frames of a sanitizer stack trace were taken for libFuzzer progress lines and
the last frame's depth was reported as the number of executed inputs. Anchor the
progress line at the start of the line and require its event to be a word: the run
above then reports 34930 executed inputs with the rest of its statistics intact.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=8d8dd308b73c4bb8ef921f0b01f6806656054872&name_0=NightlyFuzzers&name_1=libFuzzer%20tests

Related: #107459
@clickhouse-gh

clickhouse-gh Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [25b1e15]

Summary: ✅


AI Review

Summary

Restricts synthetic Fixed/UTC±HH:MM:SS zones to quarter-hour offsets within ±14 hours, validates session_timezone against the same rule, fixes libFuzzer progress parsing, and caps select_parser_fuzzer input length. The fuzzer-specific changes look reasonable, but the DateLUTImpl guard currently turns this into a backward-incompatible rejection of explicit DateTime/DateTime64 time zones that older versions could already persist, so the PR is not ready to merge as-is.

PR Metadata
  • If this behavior is kept, Changelog category is not semantically correct: rejecting previously accepted Fixed/UTC... type parameters is a Backward Incompatible Change, not a Bug Fix.
  • If this behavior is kept, the Changelog entry needs migration guidance explaining that old DateTime/DateTime64 schemas and Native type encodings using non-quarter-hour fixed offsets would stop loading.
  • Exact replacement category: - Backward Incompatible Change
Findings
❌ Blockers
  • [src/Common/DateLUTImpl.cpp:120] The new guard runs inside DateLUTImpl itself, so it affects every explicit DateTime/DateTime64 time zone, not just the untrusted inputs that caused the OOM. Persisted schemas reconstruct through TimezoneMixin (src/DataTypes/TimezoneMixin.h:22), ATTACH/metadata loading calls DataTypeFactory::instance().get on stored type names (src/Interpreters/InterpreterCreateQuery.cpp:632), and Native type decoding rebuilds the same types (src/DataTypes/DataTypesBinaryEncoding.cpp:607). A table or Native block written by an older version with Fixed/UTC-00:44:30 now fails to deserialize with BAD_ARGUMENTS, which is a backward-incompatible break without a compatibility setting or migration path. Suggested fix: keep this rejection out of unconditional DateLUTImpl construction; scope it to the specific untrusted runtime entry points that need bounding, or gate/apply it only to newly created metadata while preserving deserialization of already-stored schemas.
Final Verdict

❌ Changes requested. The shared DateLUTImpl check fixes the fuzzer reproducer by making previously accepted explicit time-zone names invalid everywhere, including stored metadata and Native type encodings from older versions. That compatibility break needs to be addressed before merge.

LLVM Coverage Report

Measured on commit 25b1e15.

Metric Baseline Current Δ
Lines 88.80% 88.70% -0.10%
Functions 91.70% 91.70% +0.00%
Branches 81.10% 81.20% +0.10%

Changed lines: Changed C/C++ lines covered: 32/34 (94.12%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-datetime Date/DateTime/TimeZone datatypes and date-time semantics. labels Sep 5, 2026
if (&inside_main)
chassert(inside_main);

if (!isSupportedTimeZoneName(time_zone))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turns a fuzzer hardening change into a backward-incompatible type change. DateTime(...) and DateTime64(..., ...) persist the time zone string in stored metadata and binary type encodings, and both ATTACH/metadata loading (InterpreterCreateQuery::getColumnType) and Native type decoding rebuild them through TimezoneMixin -> DateLUT::instance(time_zone_name). After this guard, an older table or Native stream that uses something like DateTime64(3, 'Fixed/UTC-00:44:30') starts throwing BAD_ARGUMENTS on deserialization even though older versions accepted and could write that schema.

If the goal is only to bound untrusted runtime inputs, this check needs to stay out of unconditional DateLUTImpl construction: scope it to the relevant entry points, or gate/apply it only to newly created metadata so already-stored schemas remain readable.

@clickhouse-gh

clickhouse-gh Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 25b1e1533 with master 29dbd618d (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

2719 translation units recompiled, 14713 s compile time in total, 2719 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 5, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Sep 5, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 5, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 6, 2026
Merged via the queue into master with commit 22fae87 Sep 6, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-libfuzzer-nightly-datelut-oom branch September 6, 2026 00:59
@zlareb1

zlareb1 commented Sep 6, 2026

Copy link
Copy Markdown
Member

TL;DR: the compatibility concern raised in review turned out to be worse in practice, so I filed #118353 with an empirical reproduction.

  1. A table persisted by 26.8.2.7 with DateTime('Fixed/UTC+00:07:00') cannot be read after upgrade — and also cannot be dropped or detached: DROP TABLE, DETACH TABLE ... PERMANENTLY and TRUNCATE all wait on the failed load job and rethrow ASYNC_LOAD_WAIT_FAILED. The only remedy is hand-editing store/.../<table>.sql offline.

  2. With async_load_databases = false the server does not start at all, on every attempt.

  3. normalizeArrowTimezone still synthesizes exactly these names (its final guard checks cctz::load_time_zone, not isSupportedTimeZoneName), so reading an Arrow file with a +00:07 timestamp column now fails with CANNOT_EXTRACT_TABLE_STRUCTURE while 26.8 reads it fine.

A control table with an on-grid name (Fixed/UTC+05:15:00) upgrades cleanly.

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 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 Sep 6, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 11, 2026
pull Bot pushed a commit to Haofei/ClickHouse that referenced this pull request Sep 14, 2026
`cctz` resolves every name of the form `libc:<suffix>` through the C library instead of the
time zone database. `libc:localtime` and `libc:UTC` are its own internal, test-only
interfaces, and any other suffix is accepted just as well and silently behaves as UTC. The
suffix is unrestricted, so this family of accepted names has no bound, and every name that
gets loaded permanently costs ~4.6 MiB in the `DateLUT` cache, which never evicts anything
because callers keep bare `const DateLUTImpl &` references into it. Measured at 4.60 MiB of
peak RSS per distinct name, growing linearly.

This is the second such family. ClickHouse#118286 bounded `Fixed/UTC±HH:MM:SS`, but
`isSupportedTimeZoneName` returns true for every name that does not start with `Fixed/`, so
the nightly `data_type_deserialization_fuzzer` has run out of memory every night since, with
its live heap in `DateLUT::getImplementation`. 50 files of that target's corpus contain
`libc:`, while `Fixed/UTC` and `posix/` appear in none, and libFuzzer blamed the empty input
on four of the eight nights - the growth is cumulative, not the fault of one input.

Rejecting the prefix also stops `toDateTime(0, 'libc:whatever')` from answering with a UTC
value instead of reporting the name back.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=30c98e714f85f24e60583935bbe38b5bbb65aa2d&name_0=NightlyFuzzers&name_1=libFuzzer%20tests&name_1=libFuzzer%20tests

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
pull Bot pushed a commit to sjoerd2025/ClickHouse that referenced this pull request Sep 22, 2026
`isSupportedTimeZoneName` was a deny-list of two prefixes, `libc:` and `Fixed/`, so acceptance
of every other name was delegated to whatever `cctz`'s filesystem fallback could open. That set
is not the time zone database. `cctz` resolves a name as a path under the time zone database
directory, and with a `file:` prefix as an arbitrary path, so one zone has unboundedly many
names: `Europe/./Amsterdam`, `Europe//Amsterdam`, `file:UTC`, `file:/usr/share/zoneinfo/UTC`,
and any number of repetitions of `./` and `/`. None of them is in `system.time_zones`, and
every distinct name that gets loaded permanently costs ~4.6 MiB in the `DateLUT` cache, which
never evicts anything because callers keep bare references into it. So the cache that the two
previous fixes were bounding was still unbounded, reachable through `toDateTime(x, '<name>')`,
the `session_timezone` setting, binary type decoding, or the time zone of an Arrow or ORC
timestamp column. Peak RSS of `clickhouse-local`, before this change:

  20 uses of `Europe/Amsterdam`                             182 MB
  20 distinct `./`-padded spellings of `Europe/Amsterdam`    303 MB
  100 distinct `./`-padded spellings of `Europe/Amsterdam`   683 MB
  100 distinct `file:` spellings of `UTC`                    679 MB

`file:` was also a way to read a file outside the time zone database directory, which is
exactly what the `CheckTimeZoneName` guard vendored into `contrib/cctz` exists to prevent: a
TZif file copied anywhere on the filesystem loaded and answered as that zone. The open happened
while `DateLUT::getImplementation` held its global mutex, so a name pointing at a FIFO or a hung
network mount would have blocked every time zone lookup server-wide.

Make the check an allow-list: a name is accepted only if it is in the time zone database linked
into the binary - which is exactly what `system.time_zones` lists, and what the documentation of
the `DateTime` type and of `session_timezone` already tell users to use - or if it is one of the
114 `Fixed/UTC±HH:MM:SS` names for the offsets a time zone can really have. So the cache holds
at most 712 entries. This closes the padded spellings and the `file:` prefix in one line,
subsumes the `libc:` prefix, and makes the message the check reports true. The `cctz` fallback
in `custom_factory` is dropped as well, so no name can reach the host's filesystem even if it
gets past the predicate.

Names that only the host's time zone database has are no longer accepted. ClickHouse ships its
own tzdata precisely so that results do not depend on the host, such a name is absent from
`system.time_zones`, and `timezone()` answering a name that no user can spell is itself wrong.
The one place where the host chooses the name is the server's own local time zone, so `DateLUT`
reports that case at startup, naming the zone and how to override it.

This does not make the cache small - the 598 names of the time zone database plus the 114 fixed
offsets still reach ~3.2 GB if all of them are used - it makes it bounded. Shrinking a
`DateLUTImpl`, or evicting entries, is a separate matter (ClickHouse#107459).

A misspelled time zone name is now reported as "Time zone X is not supported. Use a name from
`system.time_zones`, ..." instead of "Cannot load time zone X", so
`03926_arrow_fixed_offset_timezone` is updated.

`05059_formatDateTime_extralong_timezone` checked the 32-byte limit that
`formatDateTimeInJodaSyntax` puts on a time zone name, using `'Etc' || repeat('/', 26) || 'UTC'`
to reach exactly 32 bytes. That spelling is one of the ones this rejects, and the longest real
name, `America/Argentina/ComodRivadavia`, is exactly 32 bytes, so the test uses it instead: the
name the per-row reservation has to fit is a real one, and nothing longer can be constructed.

Closes: ClickHouse#120188
Related: ClickHouse#119634
Related: ClickHouse#118286

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-datetime Date/DateTime/TimeZone datatypes and date-time semantics. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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.

Enumerating time zones leads to accumulation of 2.9 GB of RAM.

5 participants