Repository navigation
Generate the fuzzer dictionary from a release binary instead of committing it - #111025
Conversation
…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]>
|
Workflow [PR], commit [82d1916] Summary: ✅
AI ReviewSummaryThis PR replaces committed Missing context / blind spots
Final Verdict✅ Approve |
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]>
…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]>
|
@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 |
|
Confirmed: the No separate PR is needed: our #108401 is the owner and is awaiting review. It removes the over-strict |
…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.
|
The two red checks are unrelated to this PR (it only touches fuzzer dictionary generation):
Addressed both review findings: brace-initialized |
|
📊 Cloud Performance Report ✅ AI verdict: 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. clickbenchFlagged queries (15 of 43)
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_officialFlagged queries (6 of 22)
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
|
…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]>
…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.
… 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]>
Co-Authored-By: Claude Fable 5 <[email protected]>
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]>
…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.
|
The Upgrade check reds on 46577c2 are unrelated to this PR:
|
|
The
The AI review verdict is now ✅ Approve and all review threads are resolved. |
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.
|
Pushed 82d1916: the remaining AI-review major is addressed ( The reds on the previous head 0f51b2a are unrelated to this change - it touches only
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):
|
|
1.
Query:
2. In that job's That query is
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. |
|
This PR might be related to nightly fuzzers not working anymore with error. Example. |
|
Confirmed related. It is a shell hygiene issue in the coverage check this PR added, not a real coverage gap.
Reproduced against the master release binary and current master sources: the shipped line under ambient 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 |
|
@groeneai where's the fix PR? |
|
Fix: #113368 Root cause was the coverage check itself, not a coverage gap. |
|
@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 |
|
@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 |
|
Acknowledged. I will reintroduce it as a new PR, since #111025 is merged and closed. Both linked failures are in scope: the One constraint I cannot work around: |
Previously the libFuzzer dictionaries under
tests/fuzz/(all.dictand theper-category
functions.dict,datatypes.dict,keywords.dict) were committedsnapshots of
system.functions,system.data_type_familiesandsystem.keywords.They are produced by
tests/fuzz/update_dict.sh, but that script was only ever runby hand, so the committed files drifted from the actual grammar.
This generates
all.dictin CI instead:libFuzzer testsjob (the only place the fuzzers are actually run - nightly)now requires the
arm_releasebinary and regenerates the dictionary from it rightbefore fuzzing, so it always matches the exact revision under test.
update_dict.shnow takes a binary viaCLICKHOUSE_BINand anOUTPUT_DIR,writes its intermediate per-category dicts to a temporary directory, and merges
them with the one remaining committed dictionary,
dictionaries/old.dict(acurated set of multi-word keywords and historical names that cannot be derived
from the system tables).
tests/fuzz/generate_source_dict.shderives a dictionary (about 2500 tokens)from the source tree instead: parser keywords from
CommonParsers.h(the sourceof
system.keywords), function / aggregate function / table function names andaliases from their registration code, and data type families from
src/DataTypes, merged with the curateddictionaries/old.dict. Unlike acommitted snapshot, it regenerates with the sources, so it cannot drift.
It is used in two places:
codegen_select_fuzzerseeds its build-time grammar from it.tests/fuzz/build.shstages it as a fallbackall.dictnext to the.optionsfiles in the build output, so direct consumers of thefuzzersbuild (local runs, OSS-Fuzz) still find the dictionary the
.optionsfilesreference. The nightly job overrides it with the authoritative
binary-derived one.
all.dict,functions.dict,datatypes.dict,keywords.dict) are deleted; only the curateddictionaries/old.dictremains.Generation is kept in the test job (not the build) on purpose: the fuzzers build runs
early in every PR, while
arm_releaseonly finishes after all regular builds, sorequiring the binary in the build would push the fuzzers build far down the PR
critical path.
NightlyFuzzersgains thearm_releasebuild as a provider; itsconfig is left identical to
MasterCI's so the digest matches and it is normally acache hit.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Generate the
libFuzzerdictionary 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