Skip to content

Generate the fuzzer dictionary from a release binary instead of committing it - #111025

Merged
alexey-milovidov merged 28 commits into
masterfrom
fuzz-dict-generate-from-binary
Jul 30, 2026
Merged

alexey-milovidov merged 28 commits into
masterfrom
fuzz-dict-generate-from-binary

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Previously the libFuzzer dictionaries under tests/fuzz/ (all.dict and the
per-category functions.dict, datatypes.dict, keywords.dict) were committed
snapshots of system.functions, system.data_type_families and system.keywords.
They are produced by tests/fuzz/update_dict.sh, but that script was only ever run
by hand, so the committed files drifted from the actual grammar.

This generates all.dict in CI instead:

  • The libFuzzer tests job (the only place the fuzzers are actually run - nightly)
    now requires the arm_release binary and regenerates the dictionary from it right
    before fuzzing, so it always matches the exact revision under test.
  • update_dict.sh now takes a binary via CLICKHOUSE_BIN and an OUTPUT_DIR,
    writes its intermediate per-category dicts to a temporary directory, and merges
    them with the one remaining committed dictionary, dictionaries/old.dict (a
    curated set of multi-word keywords and historical names that cannot be derived
    from the system tables).
  • For build-time consumers, where no runnable binary is available, a new
    tests/fuzz/generate_source_dict.sh derives a dictionary (about 2500 tokens)
    from the source tree instead: parser keywords from CommonParsers.h (the source
    of system.keywords), function / aggregate function / table function names and
    aliases from their registration code, and data type families from
    src/DataTypes, merged with the curated dictionaries/old.dict. Unlike a
    committed snapshot, it regenerates with the sources, so it cannot drift.
    It is used in two places:
    • codegen_select_fuzzer seeds its build-time grammar from it.
    • tests/fuzz/build.sh stages it as a fallback all.dict next to the
      .options files in the build output, so direct consumers of the fuzzers
      build (local runs, OSS-Fuzz) still find the dictionary the .options files
      reference. The nightly job overrides it with the authoritative
      binary-derived one.
  • The removed generated dictionaries (all.dict, functions.dict, datatypes.dict,
    keywords.dict) are deleted; only the curated dictionaries/old.dict remains.

Generation is kept in the test job (not the build) on purpose: the fuzzers build runs
early in every PR, while arm_release only finishes after all regular builds, so
requiring the binary in the build would push the fuzzers build far down the PR
critical path. NightlyFuzzers gains the arm_release build as a provider; its
config is left identical to MasterCI's so the digest matches and it is normally a
cache hit.

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Generate the libFuzzer dictionary from the current build in CI instead of committing a snapshot, so nightly fuzzing and standalone fuzzer builds use a dictionary matching the actual ClickHouse grammar.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

…tting it

The libFuzzer dictionaries under `tests/fuzz/` (`all.dict` and the per-category
`functions.dict`, `datatypes.dict`, `keywords.dict`) were committed snapshots of
`system.functions`, `system.data_type_families` and `system.keywords`. They were
produced by `tests/fuzz/update_dict.sh` but that script was only ever run by hand,
so the committed files drifted from the actual grammar.

Generate `all.dict` in CI instead. The `libFuzzer tests` job (the only place the
fuzzers are actually run - nightly) now requires the `arm_release` binary and
regenerates the dictionary from it right before fuzzing, so it always matches the
exact revision under test. `update_dict.sh` was reworked to take a binary via
`CLICKHOUSE_BIN` and an `OUTPUT_DIR`, write its intermediate per-category dicts to
a temporary directory, and merge them with the one remaining committed dictionary,
`dictionaries/old.dict` (a curated set of multi-word keywords and historical names
that cannot be derived from the system tables).

The `codegen_select_fuzzer` embeds its grammar at build time, where no runnable
binary is available, so it now seeds its grammar from the curated
`dictionaries/old.dict` instead of the removed `all.dict`.

Generation is kept in the test job (not the build) on purpose: the fuzzers build
runs early in every PR, while `arm_release` only finishes after all regular
builds, so requiring the binary in the build would push the fuzzers build far down
the PR critical path. `NightlyFuzzers` gains the `arm_release` build as a provider;
its config is left identical to MasterCI's so the digest matches and it is
normally a cache hit.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [82d1916]

Summary: ✅


AI Review

Summary

This PR replaces committed libFuzzer dictionary snapshots with generated dictionaries: the nightly libFuzzer tests job now rebuilds all.dict from the arm_release binary, while build-time consumers use a source-derived fallback for codegen_select_fuzzer and packaged fuzzers. After reviewing the current diff, reading the full prior discussion, re-running tests/fuzz/generate_source_dict.sh on the final head, and checking the current PR CI report, I did not find any remaining correctness or CI-plumbing issues in the final state.

Missing context / blind spots
  • ⚠️ I could not run tests/fuzz/update_dict.sh locally against a release clickhouse binary because no suitable binary artifact is present in this workspace. The current PR CI is green, so the binary-vs-source coverage check appears to pass there.
Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Jul 20, 2026
Comment thread tests/fuzz/build.sh Resolved
Address review on #111025: the `fuzzers` build output kept shipping
`.options` files with `dict = all.dict` but no `all.dict` next to them,
and `codegen_select_fuzzer` seeded its grammar from the small curated
`dictionaries/old.dict` only, so its token set would drift from the
actual grammar again.

Add `tests/fuzz/generate_source_dict.sh`, which derives a dictionary
from the source tree without running a binary: parser keywords from
`CommonParsers.h` (the source of `system.keywords`), function /
aggregate function / table function names and aliases from their
registration code, and data type families from `src/DataTypes`, merged
with the curated `dictionaries/old.dict` (about 2500 tokens). Unlike
the removed committed snapshot, it regenerates with the sources, so it
cannot drift.

Use it in `tests/fuzz/build.sh` to stage a fallback `all.dict` in the
build output for direct consumers (local runs, OSS-Fuzz) - the nightly
job still overrides it with the authoritative binary-derived one - and
in `codegen_select_fuzzer` to seed its build-time grammar.

Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov and others added 2 commits July 20, 2026 19:53
…ll.dict in the artifact

- `generate_source_dict.sh` now matches multiline conditional `constexpr ... name`
  initializers (e.g. `IPv4StringToNum*` in `FunctionsCodingIP.cpp`), trait name
  constants (e.g. `makeDateName` in `makeDate.cpp`), and `register*` calls with a
  line break before the name literal (e.g. `Date32` in `DataTypeDate32.cpp`).
- `codegen.dict` now depends on the scanned sources via a `CONFIGURE_DEPENDS` glob,
  so incremental builds regenerate the grammar when registration code changes.
- The `fuzzers` CI artifact now includes `build/programs/all.dict`, so the
  `.options` files referencing `dict = all.dict` have a matching file next to them.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111025&sha=022c3a646d9fe725014437a408cb1237e2c59be1&name_0=PR&name_1=AST%20fuzzer%20%28amd_tsan%29 and provide a fix in a separate PR. The AST fuzzer (amd_tsan) failure (Logical error: ScatterExchangeStep should have one source shard in makeDistributedPlan over a Merge table) is unrelated to this PR; it is tracked in #107946 and a fix is already in progress in #108401.

Comment thread ci/defs/job_configs.py Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

Confirmed: the AST fuzzer (amd_tsan) LOGICAL_ERROR (ScatterExchangeStep should have one source shard) is unrelated to this PR. It is the chronic issue #107946 family, 36 distinct PRs plus 1 master run in the last 30 days, so it fires independently of the fuzzer-dictionary change here.

No separate PR is needed: our #108401 is the owner and is awaiting review. It removes the over-strict source_shards.size() != 1 guard in ScatterExchangeStep::createSinkAndSourcePair. The step already builds ShuffleSend/ShuffleReceive, which handle N source buckets, so a multi-bucket source (produced when a Merge table's children are Distributed and each per-child plan carries its own scatter) repartitions as a plain shuffle instead of throwing. It also adds a regression test (04367_distributed_plan_merge_scatter_multishard) for the Merge-over-Distributed reproducer.

…ource dictionary

The `constexpr ... name` matcher in `generate_source_dict.sh` required an `=`
initializer, so registrations using brace initialization, such as
`static constexpr auto name{"JSONHas"};`, were dropped. Accept both `=` and
`{` initializers; this covers the `NameJSON*` family in `FunctionsJSON.cpp`,
`JSON_EXISTS`/`JSON_VALUE`/`JSON_QUERY` in `FunctionSQLJSON.h`, and
`arrayLevenshteinDistance*`/`arraySimilarity` in `arrayLevenshtein.cpp`.
…s)` digest

`tests/fuzz/build.sh` runs as a `POST_BUILD` step of the `fuzzers` target and
stages the `.options` files and a source-derived fallback `all.dict` into the
build output, so the produced `ARM_FUZZERS` artifact depends on the inputs
under `tests/fuzz`, which the shared build digest does not hash. Praktika
could therefore cache-hit `Build (arm_fuzzers)` after a dictionary-generation
change and hand `libFuzzer tests` a stale `codegen_select_fuzzer` and fallback
`all.dict`. Extend the digest of the fuzzers build only (via a new
`Job.Config.set_digest_config`, symmetric to the existing setters), so the
other builds are unaffected.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The two red checks are unrelated to this PR (it only touches fuzzer dictionary generation):

Addressed both review findings: brace-initialized name constants are now extracted (9cb0098), and Build (arm_fuzzers) got its own digest including ./tests/fuzz/ (c1687a1). Also merged master.

Comment thread tests/fuzz/generate_source_dict.sh Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 37 queries analysed

Release-transition baseline: compared against the last 26.7 master because no 26.8 master baseline exists at or before the trusted base-commit anchor.

This PR changes only libFuzzer dictionary generation: the nightly fuzzers CI workflow, fuzzer build cache digests, the codegen_fuzzer CMake wiring, and the tests/fuzz shell scripts (all.dict is now derived from the binary/sources instead of committed). No server query-execution code is touched, so none of the flagged per-query deltas — including the large apparent speedups on ClickBench Q20/Q23/Q24/Q26 and TPC-H Q2/Q8/Q9/Q18/Q20 — can be attributed to this change; they reflect base-vs-source build and version differences (base v26.7 vs source v26.8) and, for several queries, wide base variance bands. All flagged queries have therefore been downgraded to not_sure, and the envelope suppressions on ClickBench Q9 and Q18 are consistent with the diff.

clickbench

⚠️ 15 inconclusive

Flagged queries (15 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 3 not_sure 394 53 ×7.4 faster <0.0001 The PR only changes libFuzzer dictionary generation and CI config, so this ×7.4 faster reading is base-vs-source build/version variance, not a real effect.
⚠️ 4 not_sure 618 293 ×2.1 faster <0.0001 No query-execution code is touched by this fuzzer-tooling PR; the ×2.1 faster delta reflects build/version differences between base and source.
⚠️ 5 not_sure 856 384 ×2.2 faster 0.0007 This ×2.2 faster reading cannot be attributed to a PR that only edits fuzzer dictionary scripts and CI config; treat it as build/version variance.
⚠️ 9 not_sure 339 375 +10.6% <0.0001 The +10.6% delta sits within master's current variance band and the PR touches no execution path, so suppression to not_sure is correct.
⚠️ 11 not_sure 221 172 -22.2% <0.0001 The PR only changes libFuzzer dictionary generation and CI config, not any query-execution path, so this -22.2% shift is build/version variance, not a real improvement.
⚠️ 18 not_sure 1262 1387 +9.9% 0.0065 The +9.9% delta is within master's variance band and the PR touches no execution code, so keeping it as not_sure is consistent with the diff.
⚠️ 20 not_sure 3310 219 ×15.1 faster 0.0039 This fuzzer-tooling/CI PR touches no query-execution code, so the ×15.1 faster reading is build/version variance between base and source, not a real speedup.
⚠️ 23 not_sure 7791 80 ×97.4 faster <0.0001 The PR only edits fuzzer dictionary scripts and CI config; a ×97.4 faster jump with a huge base variance band is cross-build/version noise, not this change.
⚠️ 24 not_sure 850 57 ×14.9 faster <0.0001 No execution path is touched by this PR, so the ×14.9 faster reading reflects base-vs-source build/version differences rather than a real effect.
⚠️ 25 not_sure 957 144 ×6.6 faster 0.0022 This ×6.6 faster delta cannot come from a PR limited to fuzzer dictionary generation and CI config; it is build/version variance.
⚠️ 26 not_sure 839 57 ×14.7 faster <0.0001 The PR touches no server query code, so the ×14.7 faster reading is cross-build/version noise, not a real improvement.
⚠️ 28 not_sure 2788 1081 ×2.6 faster 0.0228 This ×2.6 faster reading (with noisy underlying measurements) is unrelated to a fuzzer-tooling PR; treat it as build/version variance.
⚠️ 33 not_sure 1448 1359 -6.2% <0.0001 The PR only changes fuzzer dictionary generation and CI config, not any execution path, so this -6.1% shift is build/version variance, not a real improvement.
⚠️ 34 not_sure 4485 1330 ×3.4 faster 0.0003 No query-execution code is touched here, so the ×3.4 faster reading reflects base-vs-source build/version differences, not this change.
⚠️ 35 not_sure 432 182 ×2.4 faster 0.0076 This ×2.4 faster reading is unrelated to a PR limited to fuzzer dictionary scripts and CI config; it is build/version variance.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 6 inconclusive

Flagged queries (6 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 0 not_sure 494 67 ×7.4 faster <0.0001 The ×7.4 faster reading cannot be attributed to a fuzzer-tooling/CI PR; it reflects base-vs-source build/version differences.
⚠️ 2 not_sure 474 60 ×7.9 faster <0.0001 This PR only changes libFuzzer dictionary generation and CI config, not any execution path, so the ×7.9 faster reading is build/version variance.
⚠️ 8 not_sure 384 165 ×2.3 faster <0.0001 No server query code is touched, so the ×2.3 faster reading is cross-build/version noise rather than a real speedup.
⚠️ 9 not_sure 201 98 ×2.1 faster <0.0001 The PR is limited to fuzzer dictionary scripts and CI config, so this ×2.1 faster delta is build/version variance, not a real effect.
⚠️ 18 not_sure 228 73 ×3.1 faster <0.0001 No execution path is touched by this PR, so the ×3.1 faster reading reflects base-vs-source build/version differences.
⚠️ 20 not_sure 406 112 ×3.6 faster <0.0001 This ×3.6 faster reading (with noisy source measurements) cannot come from a fuzzer-tooling/CI PR; treat it as build/version variance.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: b14a691a-d4c5-4505-a15c-6a49bd4cd9bf
  • MIRAI run: ba1559f8-8166-43c3-8eeb-ce4be8c4f3dc
  • PR check IDs:
    • clickbench_852932_1785350971
    • clickbench_853049_1785350976
    • clickbench_853150_1785350986
    • tpch_adapted_1_official_853252_1785350991
    • tpch_adapted_1_official_853356_1785351012
    • tpch_adapted_1_official_853510_1785351034

…source dictionary

Some functions and aggregate functions are registered as
`factory.registerFunction(Data::getName(), ...)`, where `getName` is a
`static const char * getName() { return "..."; }` accessor. The
registration call itself carries no string literal, so the previous
passes missed `contingency`, `cramersV`, `cramersVBiasCorrected`, and
`theilsU`, which the deleted `all.dict` snapshot had contained.

Add a pass extracting the string literal returned by such `getName`
accessors under `src/Functions`, `src/AggregateFunctions`, and
`src/TableFunctions`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread tests/fuzz/generate_source_dict.sh Resolved
Comment thread tests/fuzz/generate_source_dict.sh Resolved
…ource dictionary

The source-derived fallback dictionary now mirrors the authoritative
binary-derived one more closely, as requested in the AI review:

- Combinator-expanded aggregate function names (`sumIf`, `avgIf`,
  `quantileState`, `sumArgMin`, ...) are generated by crossing aggregate
  function names (and aliases) from `src/AggregateFunctions` with the
  combinator suffixes the combinators register under, mirroring the
  `system.functions CROSS JOIN system.aggregate_function_combinators`
  step in `update_dict.sh`. `codegen_select_fuzzer` consumes each row as
  a single terminal, so the expanded token has to be emitted explicitly.
- Window function names and aliases (`rank`, `denseRank`, `dense_rank`,
  `row_number`, `lag`, `lead`, ...) are registered in
  `src/Processors/Transforms/WindowTransform.cpp`, outside the four
  scanned directories, so that file is now scanned too.
Comment thread tests/fuzz/generate_source_dict.sh Resolved
alexey-milovidov and others added 3 commits July 22, 2026 11:47
… coverage in CI

Extend `generate_source_dict.sh` with the registration patterns the review
found missing: plain `const` name constants including out-of-class template
specializations (`polygonsUnionCartesian`, `widthBucket`, `icebergBucket`),
names carried by a local `String` variable (the `in`/`globalIn`/`nullIn`/
`notNullIn` family), looped-over alias lists (`group_concat`, `string_agg`),
`registerAliasUnchecked` (`array_concat_agg`), name constants in
`src/Formats` (`structureToCapnProtoSchema`, `structureToProtobufSchema`),
and window functions in the combinator cross (`dense_rankIf`, `lagArgMax`).

Names composed at compile time (`toIntervalDay`, `tuplePlus`,
`emptyArrayUInt8`, `L2Normalize`, `inIgnoreSet`) cannot be derived by
scanning; they move to the curated `old.dict`. To keep all of this honest,
`update_dict.sh` - which runs in the nightly `libFuzzer tests` job against a
real binary - now fails when the source-derived dictionary does not cover the
binary-derived one, so extractor gaps cannot regress silently. Verified
locally: the source-derived dictionary now covers 100% of the binary-derived
`all.dict`.

Also add `src/Formats` and `src/Processors/Transforms/WindowTransform.cpp`
to the `codegen.dict` custom-command dependencies so editing any scanned
registration site regenerates the grammar on an incremental build.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread tests/fuzz/update_dict.sh Resolved
alexey-milovidov and others added 2 commits July 22, 2026 18:36
The binary-derived `all.dict` now includes `system.table_functions`, so
the no-drift coverage check in `update_dict.sh` verifies table function
names too. The source-derived extractor gains the passes that check
revealed as missing: name-helper functions returning literals
(`mergeTreeAnalyzeIndexFunctionName` in
`TableFunctionMergeTreeAnalyzeIndexes.cpp`), `names` array initializers
(`generate_series`/`generateSeries`), and the object storage / data lake
table function definitions in
`src/Storages/ObjectStorage/StorageObjectStorageDefinitions.h` (`s3`,
`gcs`, `iceberg*`, `deltaLake*`, `paimon*`, `hudi*` and their
`*Cluster` variants), which is also added to the codegen dictionary's
CMake dependencies. Verified locally: the coverage check passes against
a real binary.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread tests/fuzz/update_dict.sh Resolved
…onary and cover the seed corpus in the fuzzers build digest

std::string_view name constants are never SQL registrations (the factory
registration paths take String, which string_view does not implicitly
convert to); the ones in the scanned trees name foreign entities - the
AssemblyScript runtime exports __new / __pin / __unpin and the wasm host
ABI clickhouse_create_buffer - or hold the display literals of the
dateName month_names / day_names tables. 24 tokens removed, 0 added; the
update_dict.sh coverage check stays green against a fresh master binary.

tests/fuzz/build.sh also repacks tests/queries/0_stateless/*.sql into the
*_seed_corpus.zip outputs, so the arm_fuzzers digest now includes that
directory too - a stateless test change can no longer cache-hit a stale
seed corpus for NightlyFuzzers.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Upgrade check reds on 46577c2 are unrelated to this PR:

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Upgrade check (amd_release) reds on 4f77590 are unrelated to this PR (it only touches fuzzer-dictionary tooling and CI plumbing), and both fixes have now merged to master, so I merged master (9ae5080) to clear them:

The AI review verdict is now ✅ Approve and all review threads are resolved. tests/fuzz/generate_source_dict.sh re-verified against the merged tree (6358 tokens, unchanged).

alexey-milovidov and others added 4 commits July 25, 2026 14:14
The review found `_table_function` (from `getDatabaseName` of
`ITableFunction`) and `c` (from the local `String column_name = "c"` in
`FunctionGenerateRandomStructure.cpp`) in the source-derived dictionary.
Both carrier shapes are excluded as a class, not per token:

- The helper-body pass now requires the helper name to say it returns a
  *function* name (`getName` or a free `*FunctionName` helper); helpers
  naming another entity kind (`getDatabaseName`) return names from a
  different namespace.
- The String-local pass now requires the variable to flow into a
  `register*` call in the same file; a never-registered name local
  (`column_name`, `result_name`) carries no registered name.
- The name-constant passes now require a bare `name` / `names` or a
  CamelCase `*Name(s)` trait constant; snake_case compounds qualify the
  name with another entity kind (`mandatory_argument_names` /
  `optional_argument_names` in `makeDate.cpp`, `element_names` in
  `MVTBoundingBox.cpp`, `storage_engine_name` in
  `StorageObjectStorageDefinitions.h`).
- The mechanical kernel rule gains the `Transform` composition suffix
  (`ZeroTransform` carries the fragment `Zero`).

Net effect: 58 source-only tokens removed, 0 added (6358 -> 6300).
Verified against a current master release binary: the coverage check in
`update_dict.sh` passes - all binary-derived tokens remain covered.

Co-Authored-By: Claude Fable 5 <[email protected]>
…es from the source dictionary

The source-derived dictionary emitted four tokens outside the runtime SQL
surface: `trap` (whose whole carrier `src/Functions/trap.cpp`, including its
`REGISTER_FUNCTION`, is compiled out with `#if 0`) and the internal
`__topKFilter` / `__quantizeDistance` / `__productQuantizationDistance`, whose
implementation classes are built by query plan optimizations directly and are
never registered in `FunctionFactory`.

Both carrier shapes are excluded as a class rather than by token:

- string literals inside `#if 0` regions of the scanned trees are subtracted,
  unless the same name also has a live carrier elsewhere;
- an internal `__` name is kept only if some file naming it also registers
  something, which keeps the registered internal functions
  (`__bitWrapperFunc`, `__getScalar`, `__actionName`, `__applyFilter`, ...).

Net effect on the same tree: 4 tokens removed, 0 added (6300 -> 6296). The
coverage check of `update_dict.sh` stays green against a release binary.
…from-binary

Conflicts: `tests/fuzz/all.dict`, `tests/fuzz/dictionaries/datatypes.dict`,
`tests/fuzz/dictionaries/functions.dict` - modified on master, deleted by this
pull request, which generates the dictionary instead of committing it; the
deletion is kept.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Pushed 82d1916: the remaining AI-review major is addressed (#if 0 names and unregistered internal __ names are no longer harvested by tests/fuzz/generate_source_dict.sh), and master is merged (269 commits behind; the only conflicts were tests/fuzz/all.dict and the per-category dictionaries, modified on master and deleted here - the deletion is kept, since this pull request generates them).

The reds on the previous head 0f51b2a are unrelated to this change - it touches only tests/fuzz/, the fuzzer CI wiring and the codegen_select_fuzzer grammar generation, not the server:

  • Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel): Logical error: Got read request from replica A for unknown stream B. (STID: 5217-5b3d) - Logical error: Got read request from replica A for unknown stream B. (STID: 5217-5b3d) #110518, plus the Server died collateral of the same run.
  • Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3): Scraping system tables - Scraping system tables #110816.
  • Stateless tests (amd_tsan, s3 storage, parallel, 1/3): 03291_json_big_structure_deserialization timeout, flagged flaky by the harness itself (the rerun with the same randomized settings passed).

Two of them have no tracking issue yet:

@groeneai, investigate these two failures and provide a fix in separate pull requests (if a fix is already in progress, please link it here):

@groeneai

Copy link
Copy Markdown
Collaborator

1. Segmentation fault (STID: 3502-48fc): fix already in progress: #109932.

fatal.log for that run carries the frames below the ones the report shows:

3.  ActionsDAG::evaluatePartialResult (ActionsDAG.cpp:1507)   <- SEGV read
5.  SourceStepWithFilter::applyPrewhereActions
6.  MergeTreeSelectProcessor::transformHeader
7.  ReadFromMergeTree::ReadFromMergeTree (ctor, ReadFromMergeTree.cpp:449)
9.  ReadFromMergeTree::clone (ReadFromMergeTree.cpp:3552)
11. QueryPlan::clone
12. DirectJoinMergeTreeEntity::getByKeys (DirectJoinMergeTreeEntity.cpp:176)
13. DirectKeyValueJoin::joinBlock

Query: SELECT DISTINCT ... FROM events AS t0 INNER JOIN attributes AS t1 ON t1.EventId = t0.Id PREWHERE equals(log10(2147483648), EventId) ..., with join_algorithm = 'direct'.

ReadFromMergeTree::clone() copies SelectQueryInfo by value, so prewhere_info is a single shared_ptr shared by the lookup plan and every per-batch clone getByKeys makes. One lookup's plan optimization prunes that shared prewhere DAG in place while another lookup's clone constructor is still walking it through transformHeader -> applyPrewhereActions -> updateHeader, and the constructor reads a freed node. Same root cause as #110241 (SIGSEGV in buildFilterActionsDAG, closed as a duplicate of #109932), different victim frame. Still live on master: clone() at ReadFromMergeTree.cpp:3546 passes query_info by value. #109932 deep-copies prewhere_info and row_level_filter per clone; its head is not an ancestor of 0f51b2a, so this run predates it.

2. Logical error '!part.empty()' (STID: 2735-47bf): the label is wrong, which is why no issue matches it. The tracking issue is #110133.

In that job's clickhouse-server.err.log (142834 lines, 54 <Fatal>; servers 1 and 2 have none) the string part.empty occurs exactly once, at line 70795, and it is a comment inside the query text echoed by an expected TYPE_MISMATCH exception from 04367_lambda_arg_backquoted_dot_no_logical_error.sql, whose comments quote the assertion the test guards against. The only genuine abort is 12 minutes later:

<Fatal> Logical error: 'Arguments of 'multiply' have incorrect data types:
        'n' of type 'Int256', '0.123' of type 'Float64''
FunctionBinaryArithmetic.h:3360 -> IFunction.h:532 executeImplDryRun
  -> ActionsDAG.cpp:1286 executeActionForPartialResult -> :1568 evaluatePartialResult -> :1402 updateHeader
  -> ExpressionTransform::transformHeader -> InterpreterSelectQuery::executeImpl
(query_id 06a16121-6762-4409-bc28-376fa3d44dff,
 query: SELECT n * 0.123 FROM (SELECT * FROM tbl_03007_1))

That query is 03915_exchange_tables_race.sh, so this is #110133: EXCHANGE TABLES swaps n between Int256 and Float64 while the SELECT is being planned. Server died and Scraping system tables in the same report are collateral of that single abort.

log_parser.py names the failure from the first Logical error.* match in the log, and the echoed comment precedes the real message, hence the !part.empty() label. Under this one STID, CIDB has 82 hits labelled !part.empty(), 90 labelled Arguments of 'A' have incorrect data types and 3 with the multiply message spelled out, all in 30 days, so the label split is noise rather than three bugs.

Fixes in progress: #110048 (yours) for the root cause, #109747 to avoid the abort when a type mismatch surfaces during partial result evaluation, and #111435 (yours) plus #111708 for the misnaming itself.

@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 Jul 30, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 30, 2026
Merged via the queue into master with commit d67bfc4 Jul 30, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the fuzz-dict-generate-from-binary branch July 30, 2026 08:28
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 30, 2026
@rienath

rienath commented Aug 3, 2026

Copy link
Copy Markdown
Member

This PR might be related to nightly fuzzers not working anymore with

Traceback (most recent call last):
File "/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/./ci/jobs/libfuzzer_test_check.py", line 495, in
main()
File "/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/./ci/jobs/libfuzzer_test_check.py", line 449, in main
generate_dictionary(fuzzers_path, repo_path, docker_image)
File "/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/./ci/jobs/libfuzzer_test_check.py", line 138, in generate_dictionary
subprocess.check_call(cmd, shell=True)
File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'docker run --rm --user 1000:1000 --workdir=/fuzzers --volume=/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/ci/tmp:/fuzzers --volume=/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse:/repo:ro -e CLICKHOUSE_BIN="/fuzzers/clickhouse" -e OUTPUT_DIR="/fuzzers" clickhouse/stateless-test:fbbff9a52c8be0087d39_arm bash /repo/tests/fuzz/update_dict.sh' returned non-zero exit status 1.

error. Example.

@groeneai

groeneai commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Confirmed related. It is a shell hygiene issue in the coverage check this PR added, not a real coverage gap.

tests/fuzz/update_dict.sh:64 pins LC_ALL=C on both sort children but not on comm itself, and the container inherits ENV LC_ALL en_US.UTF-8 from ci/docker/test-base/Dockerfile:160. So comm reads C-ordered input under UTF-8 collation, and the two disagree on multi-word keywords: C sorts "ADD INDEX" before "ADD" (0x20 < 0x22), en_US.UTF-8 the reverse. comm exits 1 on detected disorder and the script runs under set -euo pipefail, so the command substitution aborts before if [ -n "$MISSING_TOKENS" ] is evaluated. That is why the log shows the three comm: warnings but never the script's own error: tokens present in ... line with the token list.

Reproduced against the master release binary and current master sources: the shipped line under ambient LC_ALL=en_US.UTF-8 gives rc 1 plus those exact three warnings; adding LC_ALL=C to comm gives rc 0 with zero missing tokens, and still fails correctly when I drop a token from the source dictionary. generate_source_dict.sh:80 already uses LC_ALL=C comm, so this is the only affected call site.

Nightly has died in dictionary generation on every scheduled run since 2026-07-31, the first night this check reached master, before any fuzzer runs. I will link the fix PR here.

[Corrected 2026-08-05: I originally wrote "red every night since 2026-07-28" and attributed all of it to this abort. Only 07-31 onward are. 07-28 to 07-30 were red for an unrelated data_type_deserialization_fuzzer finding, and the 07-30 run started at 04:15Z, before this PR merged at 08:28Z.]

@rienath

rienath commented Aug 4, 2026

Copy link
Copy Markdown
Member

@groeneai where's the fix PR?

@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Fix: #113368

Root cause was the coverage check itself, not a coverage gap. comm was left on the container's
ambient en_US.UTF-8 while both its sort children were pinned to LC_ALL=C; the collations
disagree on the quoted multi-word keywords, so comm reported disorder and exited 1, and
set -euo pipefail killed the command substitution before the check was evaluated. That is why
the log shows the three comm: warnings and never the script's own token list. The dictionary
itself was generated correctly.

@rienath

rienath commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

@alexey-milovidov could we revert this PR? Ever since this PR was merged, the job is red. Fixing the aborts (#113368) also leaves the job red, but with another issue introduced also by this PR.

Let's revert and create a PR with nightly fuzzers workflow on top. We can fix it and merge once nightly fuzzers become green

@rienath

rienath commented Aug 17, 2026

Copy link
Copy Markdown
Member

@groeneai feel free to reintroduce the PR. Please fix all the issues (1, 2) that made NightlyFuzzers red. If anything else related to your changes makes it fail, please fix it too. When you reintroduce, make the description laconic and run NightlyFuzzers action on branch. Also mention in PR itself that it shouldn't be merged until NightlyFuzzers ran on that branch is green. Ask person who is area expert for a review

@groeneai

Copy link
Copy Markdown
Collaborator

Acknowledged. I will reintroduce it as a new PR, since #111025 is merged and closed.

Both linked failures are in scope: the comm locale abort, and the release binary being enumerated as a fuzzer in /fuzzers (your 2026-08-08 dispatch of libfuzzer-dict-fix ended OK: 20, FAIL: 1, the one FAIL being ./clickhouse -artifact_prefix=...). The description will be laconic, the PR will state it must not be merged until NightlyFuzzers is green on the branch, and I will cc the area expert for review.

One constraint I cannot work around: workflow_dispatch on nightly_fuzzers.yml returns 403 "Must have admin rights to Repository" for me, and all three past manual runs used branches in ClickHouse/ClickHouse, which I have no push access to. A fork run is not an option either, since every job is runs-on: [self-hosted, ...]. So I can prepare the branch but not run the workflow on it. If you dispatch it once the PR is up, I will fix whatever it reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement 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