Repository navigation
Extract loop-registered function names into the source-derived fuzzer dictionary - #121242
Conversation
… dictionary src/Functions/grouping.cpp registers its four specializations in a range-for over an initializer list and passes the loop variable to factory.registerFunction, so the pass that matches a string literal as the register* argument never saw __groupingForCube, __groupingForGroupingSets, __groupingForRollup and __groupingOrdinary. The binary registered four names the source-derived dictionary did not have, so the coverage check in tests/fuzz/update_dict.sh exited 1 and the nightly libFuzzer tests job died before any fuzzer target ran: the 2026-09-20 04:38 UTC master run recorded 0 fuzzer test rows against 19 on every nightly before it. The gap is the extraction, not the internal-name whitelist. The pass collecting "__" literals from files that register functions writes a file consumed only as the awk filter's whitelist, never as a token source, and it already contained all four names. Seeding it, or seeding dictionaries/old.dict (whose documented home is names composed at compile time), would not have derived them. So this adds one pass for the loop form, right after the literal-argument register-call pass. The register* call reached from the loop header is part of the match rather than the name-shaped loop variable alone, because that variable also names sets of tags (TimeSeriesTagsFunctionHelpers.cpp), backup files (UserDefinedSQLObjectsBackup.cpp), Enum elements (DataTypeFactory.cpp) and columns (gtest_NestedUtils.cpp). It is the same rule the existing String-local pass applies. The residual of matching in one regex is that the register* call has to be the loop body's first statement; the coverage check is the loud fail-safe for anything the passes miss, which is how this surfaced. Measured locally with a master debug binary: the generated dictionary goes from 6747 to 6751 tokens, added lines exactly those four names, and the coverage check from exit 1 to exit 0. The token count is source-derived and does not depend on the binary; that those four names are the whole gap is what the failing job's own log shows, with the release binary CI runs. The pass introduces no new scanned path, so the codegen dictionary's cmake dependency list is unchanged. grouping.cpp is not touched, since the loop is the idiomatic registration form. The test class appended to ci/tests/test_fuzzer_dict_codegen_deps.py runs the generator and requires the four names in its output, with a control arm running a copy whose new pattern is rewritten to a keyword no source file holds: that arm must produce none of the four, and must still produce lcase, whose only carrier is the neighbouring literal-argument pass. Co-Authored-By: Claude Opus 5 <[email protected]>
The class pinned membership only: the four __grouping* names present in the generated dictionary, absent without the new pass. The coverage check in tests/fuzz/update_dict.sh is one-way (comm -23, binary minus source), so a source-derived dictionary carrying tokens the binary does not register passes the nightly job silently, and nothing bounded what else the new pass emits. Replace the four per-name absence cases with one assertion on the exact difference between the two arms, which subsumes them in both directions. The neighbouring TestTheDictionaryTracksAnUnsuffixedCarrier pins its own delta the same way. Measured: with the pattern's register* clause and the pass's identifiers_only tail both removed, six unrelated literals reach the dictionary, the coverage check stays green, the membership cases stay green, and this assertion fails. The module docstring scoped the file to the codegen grammar's rebuild dependencies, while this class is about extraction coverage; it now names both. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 gate runs over 3 rounds, 2 findings),
Severity: ❌ blocker / Noted and not acted on, each costed: the reverse half of finding 1's assertion cannot fail for any Re-verified independently rather than taken from the author's notes: the new pass matches exactly one |
|
Workflow [PR], commit [33cfaa3] Summary: ✅ AI ReviewSummaryThis PR extends Final VerdictStatus: ✅ Approve |
| assert len(treatment) == len(control) + 1 | ||
|
|
||
|
|
||
| class TestLoopRegisteredNamesReachTheDictionary: |
There was a problem hiding this comment.
This test guards nothing at merge. Replace it with a runtime assertion that checks the job consistency where the code runs. Otherwise the fix looks good.
There was a problem hiding this comment.
Done in c91b3a3: the class is gone and the check is in generate_source_dict.sh, which runs in the fuzzers build, where CMakeLists.txt turns a non-zero exit into a FATAL_ERROR, and in the nightly job.
Two checks, after the dictionary is written:
- the loop-registration pass has to extract at least one name, so an edit to either half of its pattern (the range-for header, or the
register*call reached from it) fails the build instead of quietly shortening the dictionary; - every name it extracts has to be in the output, so a filter between the two cannot drop the internal
__names again, which is howupdate_dict.shfound them missing.
Both arms measured, against a script the checks leave byte-identical at 6751 tokens: the pass matching nothing exited 0 with 6747 tokens before and exits 1 now; the __ filter dropping internal names exited 0 with 6738 tokens and now exits 1, naming __groupingOrdinary. ./src is in the fuzzers build digest, so a change to the registration form re-runs that build rather than cache-hitting it.
One property did not survive the move: the deleted test also pinned the exact token delta, which is what catches a widened pattern adding names the binary does not have. Reproducing that at runtime needs the four expected names written into the generator, and then any new loop-registered function breaks the build, so I left it out; the coverage check in update_dict.sh is binary-minus-source only.
ci/tests/ is wired into no CI job, so the regression class this PR added for
the loop-registered names could not fail a check at merge. Replace it with two
checks inside generate_source_dict.sh, which runs in the fuzzers build, where
CMakeLists.txt turns a non-zero exit into a FATAL_ERROR, and in the nightly
libFuzzer job:
- the loop-registration pass has to extract at least one name, so an edit to
either half of its pattern (the range-for header, or the register* call
reached from it) fails the build instead of quietly shortening the
dictionary;
- every name it extracts has to be in the output, so a filter between the two
cannot drop the internal __ names again, which is how update_dict.sh found
them missing.
Both arms measured, against a script the checks leave byte-identical (6751
tokens, exit 0):
- the pass matching nothing: exit 0 and 6747 tokens before, exit 1 now;
- the __ filter dropping internal names: exit 0 and 6738 tokens before,
exit 1 now, naming __groupingOrdinary.
Requested in review.
The check added in the previous commit compared the raw loop matches against the output, but the dead code filter legitimately drops a name whose only carrier sits in an #if 0 region, so the generator failed on a tree that is correct. Reproduced with a source root whose sole carrier is an #if 0 copy of the grouping loop: exit 1 naming __groupingOrdinary before, exit 0 with no grouping name in the output now. The same root with the region enabled still yields all four names, so the arm is not passing because the pass matches nothing there. Both earlier arms still fail as they should: the pass matching nothing, and the __ filter dropping the internal names. Reported in review.
…zer dictionary src/Functions/icebergDateTransforms.cpp (ClickHouse#118583) names each specialization of its class template with an immediately-invoked lambda: static constexpr const char * name = [] { if constexpr (transform == IcebergDateTransform::Year) return "icebergYear"; else if constexpr (transform == IcebergDateTransform::Month) return "icebergMonth"; ... }(); The name-constant pass of tests/fuzz/generate_source_dict.sh takes an initializer up to its first ';', which here ends the lambda's first return statement, so only icebergYear reached the source-derived dictionary. The binary also registers icebergMonth, icebergDay and icebergHour, so the coverage check in tests/fuzz/update_dict.sh exits 1 and the nightly libFuzzer tests job stops before any fuzzer runs. The 2026-09-28 master run, which already has ClickHouse#121242, failed on exactly those three names. The pass now also accepts an immediately-invoked lambda with a brace-free body, taken up to its closing '}();'. The same alternation goes into the copy of the pattern that collects aggregate function names for the combinator expansion, so a lambda-named aggregate function also gets its <name><combinator> tokens. dictionaries/old.dict is not used: it holds names composed at compile time, and these are plain literals. Measured on this tree: the dictionary goes from 6995 to 6998 tokens, the added lines are exactly those three names and nothing is removed; of the pass's 1643 matches only the iceberg one changes, and the aggregate copy's output is unchanged. With a master debug binary the coverage check goes from exit 1 to exit 0; the failing job's log shows the same 6995 tokens and the same three names with the release binary CI runs. A lambda body with braces still falls back to the first ';', and the coverage check names what is missing, as it did here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #121214
Related: #115307
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
The nightly
libFuzzer testsjob is red since my #115307 merged:update_dict.shexits 1 and nofuzzer target runs. The 2026-09-20 master run recorded 0 fuzzer test rows, against 19 on every
nightly before it
(job log).
generate_source_dict.shhas one pass per registration shape, and the register-call pass requiresa string literal argument.
src/Functions/grouping.cppregisters its four specializations in arange-for over an initializer list and passes the loop variable, so names the binary registers were
never derived from the sources. The coverage check reported exactly those four:
__groupingForCube,__groupingForGroupingSets,__groupingForRollup,__groupingOrdinary.This adds one pass for that form. The
register*call has to be part of the same match: aname-shaped loop variable alone also matches loops over tag names, backup file names, Enum element
labels and column names.
grouping.cppis not touched; the loop is the idiomatic registration form.Locally,
update_dict.shagainst a master binary goes fromexit 1toexit 0and the dictionaryfrom 6747 to 6751 tokens: those four names and nothing else. The job runs only in
NightlyFuzzers,so this PR's own CI cannot exercise it.
ci/tests/is wired into no CI job, so the pytest class this PR first carried could not fail acheck. It is replaced by two checks inside the generator, which runs in the fuzzers build, where
CMakeLists.txtturns a non-zero exit into aFATAL_ERROR, and in the nightly job: the pass has toextract at least one name, and every name it extracts has to be in the output, so a filter between
the two cannot drop the internal
__names again. Both arms measured: the pass matching nothing, andthe
__filter dropping the internal names, each exited 0 with a short dictionary before and exits 1now. The unmodified script stays byte-identical at 6751 tokens.
Workflow [PR]
Sync PR [sync-upstream/pr/121242]
Version info
26.10.1.802-master(included in26.10and later)