Skip to content

More fuzzing for CI - #116689

Merged
PedroTadim merged 28 commits into
masterfrom
more-fuzz9
Sep 4, 2026
Merged

PedroTadim merged 28 commits into
masterfrom
more-fuzz9

Conversation

@PedroTadim

@PedroTadim PedroTadim commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

  • More streams, query parameters, and parameterized views in AST fuzzer.
  • Updated settings in BuzzHouse.
  • Empty tuples and arrays for IN operator.

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

@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a3c7e3c]

Summary: ✅


AI Review

Summary

This PR expands BuzzHouse and AST-fuzzer coverage around empty IN sets, extra settings, streaming clauses, and query parameters / parameterized views. I’m requesting changes because the new parameterized-view and Identifier-parameter branches still mostly terminate in parse or missing-parameter errors, so the advertised new coverage does not reliably reach the code paths it is supposed to fuzz.

Findings

⚠️ Majors

  • [src/Common/QueryFuzzer.cpp:3548-3587] [dismissed by author -- https://github.com/More fuzzing for CI #116689#discussion_r3880634709] callTableAsParameterizedView still guesses one to three names from {"fuzz_param_0", "fuzz_param_1", "p", "param", "id", "n"} and pairs them with arbitrary literals. Real parameterized views already in the tree use names like pdb, ptab, and pdict (tests/queries/0_stateless/04654_create_view_param_db_in_body.sql:19-20,43-44,51-52), and FunctionParameterValuesVisitor only binds assignments that are actually present before ReplaceQueryParameterVisitor throws UNKNOWN_QUERY_PARAMETER for the rest. This branch therefore spends most of its time re-testing missing-parameter failures instead of exercising parameterized-view substitution. Suggested fix: derive the parameter list from the target view AST, or at least reuse ASTQueryParameter names already seen in the corpus and generate Identifier-shaped values for Identifier placeholders.
  • [src/Common/QueryFuzzer.cpp:6978-6989,8945-8951,8975-8978] [dismissed by author -- https://github.com/More fuzzing for CI #116689#discussion_r3871456461] The new Identifier placeholders are still funneled through the generic query-parameter machinery. The mutator can rewrite {name:Identifier} into {name:Int64}-style syntax that ParserIdentifierWithOptionalParameters rejects in identifier position, and both seeding paths initialize unseen identifier parameters from generateParamValue(), so ReplaceQueryParameterVisitor::visitIdentifier substitutes names like 1, [], or {} into name_parts. That means the new identifier-parameter mutations usually fail before table/column resolution instead of exercising identifier substitution. Suggested fix: keep Identifier parameters out of generic type mutation and seed / reseed them from an identifier-only pool (database / table / column names), not from generateParamValue().
Tests
  • ⚠️ Add a focused regression that proves a fuzzed call can actually execute representative parameterized views such as v_from(pdb = ...) and v_in(ptab = ...), and that {name:Identifier} placeholders survive fuzzing as identifier parameters instead of degrading into UNKNOWN_QUERY_PARAMETER or parser failures.
Final Verdict

Status: ⚠️ Request changes

  • Make callTableAsParameterizedView bind real view signatures instead of guessed parameter names.
  • Keep Identifier parameters identifier-typed and identifier-valued throughout seeding and mutation.

LLVM Coverage Report

⚠️ No coverage measurement for commit a3c7e3c: incomplete coverage measurement: 1 of 21 shard profiles are missing: LLVM_COVERAGE_FILE_it_7.profdata.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 27, 2026
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing a3c7e3c5c with master 0ee60bc06 (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.

Object file sizes

5 object files changed (+29.10 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/clickhouse_common_io.dir/Common/QueryFuzzer.cpp.o 1.52 MiB 1.55 MiB +28.63 KiB (+1.84%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

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

Symbol sizes
Binary Symbol Master PR Δ
programs/clickhouse-keeper __cxx_global_var_init.809 new 160.62 KiB +160.62 KiB
programs/clickhouse __cxx_global_var_init.809 new 160.62 KiB +160.62 KiB
programs/clickhouse-keeper __cxx_global_var_init.794 160.62 KiB removed -160.62 KiB (-100.00%)
programs/clickhouse __cxx_global_var_init.794 160.62 KiB removed -160.62 KiB (-100.00%)

Job report

# Conflicts:
#	src/Client/BuzzHouse/Generator/SessionSettings.cpp
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread programs/client/FuzzLoop.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread programs/client/FuzzLoop.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Interpreters/executeQuery.cpp Resolved
Comment thread src/Common/QueryFuzzer.h Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
Comment thread src/Common/QueryFuzzer.cpp Resolved
@PedroTadim
PedroTadim added this pull request to the merge queue Sep 4, 2026
Merged via the queue into master with commit 38fc288 Sep 4, 2026
174 checks passed
@PedroTadim
PedroTadim deleted the more-fuzz9 branch September 4, 2026 08:41
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 4, 2026
pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Sep 24, 2026
…ST fuzzer

`{name:Identifier}` in a table position parses to an `ASTTableIdentifier` whose
`name_parts` are empty strings, carrying one `ASTQueryParameter` child per empty
part, so `ASTIdentifier::isParam` is true. `ASTTableIdentifier::getTableId`
builds a `StorageID` from those parts unconditionally, and `StorageID`'s
constructor runs `assertNotEmpty` and throws `UNKNOWN_TABLE, "Both table name
and UUID are empty"`.

`fuzzTableName`, `wrapTableAsDistributed` and `wrapTableAsMerge` checked only the
node type and then tested the result of that call for emptiness. Those emptiness
tests were dead code on this input: `getTableId` cannot return an empty
`StorageID`, and `StorageID::getTableName` asserts as well, so the read throws
before the test runs. The precondition has to be checked before the read, which
is what `callTableAsParameterizedView` in the same file already does.

The placeholder is produced by the fuzzer itself, in
`makeParameterizedIdentifier` (7cc8d90, ClickHouse#116689), and a successful fuzzed
AST is promoted to the next round's seed, so a later round reads it back as a
name. `fuzzMain` is called with no try/catch, so the exception escapes
`executeASTFuzzerQueries` and is logged by `tryLogCurrentException("ASTFuzzer")`
on the outer query's thread group; that streams it to the client's stderr and
`clickhouse-test` fails the test on non-empty stderr.

19 CIDB rows over 12 pull requests and 7 check flavours between 2026-09-04 and
2026-09-23, none on master. Per site: `fuzzTableName` 17 rows,
`wrapTableAsMerge` 2, `wrapTableAsDistributed` 0 (latent, identical ordering
behind a 1-in-40 gate).

The guard also stops the fuzzer silently de-parameterizing a reference whose
database part is a placeholder. `{pdb:Identifier}.src` is `isParam` but does not
throw, and `fuzzTableName` used to rewrite it to a plain name while the wrappers
substituted `currentDatabase()` for the parameter, producing a query that means
something different from the seed.

The regression test drives the same mutations from SQL through `fuzzQuery`, which
parses its argument and calls `fuzzMain` on it with no parameter substitution in
between. Its seed is chosen by measurement so that all three guarded helpers are
reached within 20 rows (`fuzzTableName` 30 entries, `wrapTableAsDistributed` 2,
`wrapTableAsMerge` 1, the last two behind a 1-in-40 gate each), and reverting any
one of the three guards on its own reds the test. The oracle matches the
parameter name rather than the whole `{name:Type}` text, because the fuzzer
rewrites a placeholder's declared type but never its name, and it requires every
row to keep the placeholder, because an unguarded wrapper rewrites the expression
part way through the sequence and each fuzzed AST becomes the next row's seed.

Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/35802239304/job/107027400109
Split out of ClickHouse#115786 as requested in
ClickHouse#120453 (comment)

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

Labels

pr-ci 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.

3 participants