Repository navigation
Conversation
A local distributed-plan task fragment (make_distributed_plan + distributed_plan_execute_locally) is built from a serialized query plan, not parsed, so it has no query AST. doExecuteTask passed an empty ASTSelectQuery() to logQueryStart purely to carry query_kind. An empty ASTSelectQuery has no SELECT expression list, so with log_formatted_queries = 1 logQueryStart formatted it and ASTSelectQuery::formatImpl dereferenced the absent SELECT (select()->format()), a member call on a null IAST. UBSAN reports it as "member call on null pointer of type 'DB::IAST'"; release builds hit undefined behavior / a crash. Fix: pass a null ASTPtr instead of the malformed stub. logQueryStart, logQueryFinish and logQueryException already treat a null AST as QueryKind::Select (the kind the stub was constructed to provide) and skip the interpreter-specific extension, so behavior is unchanged for query_kind while the formatting crash is avoided. Found by the BuzzHouse fuzzer (arm_asan_ubsan), STID 2791-2e42. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-30:20260610-203300 |
|
cc @davenger @KochetovNicolai — could you review this? It fixes a null pointer dereference in the local distributed-plan executor: |
|
@groeneai a link to the failure in CI, please. Remember this and do it all the time. |
|
Workflow [PR], commit [a3e77c7] Summary: ❌
AI ReviewSummaryThis PR fixes the local distributed-plan task logging path by passing a null PR Metadata
Findings
Final VerdictStatus: ✅ Approve No code changes required; update the changelog category before merge. |
|
Closing as obsolete. This fix patched session: cron:clickhouse-worker-slot-4:20260611-070900 |
A local distributed-plan task fragment is built from a serialized query plan, not parsed, so it has no query AST. doExecuteTask passed an empty ASTSelectQuery() to logQueryStart only to carry query_kind. An empty ASTSelectQuery has no SELECT expression list, so with log_formatted_queries = 1 the log path formatted it and ASTSelectQuery::formatImpl dereferenced the absent SELECT (select()->format()), a member call on a null IAST. The server aborts. Fix: pass a null ASTPtr instead of the malformed stub. logQueryStart, logQueryFinish and logQueryException already treat a null AST as QueryKind::Select (the kind the stub was constructed to provide), so behavior is unchanged for query_kind while the formatting crash is avoided. Remove the now-dead include of Parsers/ASTSelectQuery.h. Found by the BuzzHouse fuzzer (amd_msan), STID 2257-2710, on the make_distributed_plan + distributed_plan_execute_locally path. The same bug was fixed once before (PR #107079) but that fix was closed obsolete when the feature was reverted, and the feature was then re-landed with the buggy stub intact, so the fix is re-applied here. Regression test 04327_distributed_plan_local_log_formatted_queries runs the affected path; it aborts the server before this change and passes after. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a crash (null pointer dereference) that could happen when a distributed query plan was executed locally (
make_distributed_plan+distributed_plan_execute_locally) withlog_formatted_queries = 1.Description
A local distributed-plan task fragment is built from a serialized query plan, not parsed, so it has no query AST.
doExecuteTaskpassed an emptyASTSelectQuery()tologQueryStartonly to carryquery_kind. An emptyASTSelectQueryhas no SELECT expression list, so withlog_formatted_queries = 1the log path formatted it andASTSelectQuery::formatImpldereferenced the absent SELECT (select()->format()), a member call on a nullIAST.Fix: pass a null
ASTPtrinstead of the malformed stub.logQueryStart,logQueryFinishandlogQueryExceptionalready treat a null AST asQueryKind::Select(the kind the stub was constructed to provide), so behavior is unchanged forquery_kindwhile the formatting crash is avoided.Found by the BuzzHouse fuzzer (arm_asan_ubsan), STID 2791-2e42. The UBSAN report was
member call on null pointer of type 'DB::IAST'atASTSelectQuery.cpp:104.Regression test
04327_distributed_plan_local_log_formatted_queriesruns the affected path; it aborts the server before this change and passes after.