Repository navigation
Fix SIGABRT crash when aggregate_functions_null_for_empty is used with Null combinator functions - #101147
Conversation
When `aggregate_functions_null_for_empty` is enabled, the function `rewriteAggregateFunctionNameIfNeeded` calls `tryGetProperties()` and dereferences the result without checking if the optional has a value. `tryGetProperties()` returns nullopt for aggregate functions using the internal-only `Null` combinator (e.g. `sumNull`, `avgNull`), causing `std::optional::operator->` to abort. The fix adds a null check before dereferencing, matching the pattern already used 12 lines below at line 962 for the same function. This crash was hitting BuzzHouse CI on master and 12+ unrelated PRs (STID: 5390-4fca, 5390-57f3) since 2026-03-22. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pre-PR Validation Gate (Session: cron:clickhouse-ci-task-worker:20260330-011500)a) Deterministic repro? ✅ Yes. SELECT sumNull(number) FROM numbers(10) SETTINGS aggregate_functions_null_for_empty = 1;Crashes 100% of the time on the unfixed binary. Signal 6 (SIGABRT) at b) Root cause explained? ✅ Yes. c) Fix matches root cause? ✅ Yes. d) Test intent preserved / New tests added? ✅ Yes. e) Demonstrated in both directions? ✅ Yes.
|
|
cc @vdimir @novikd — could you review this? One-line fix for a server crash (SIGABRT) in |
|
Workflow [PR], commit [a516da3] Summary: ❌
AI ReviewSummaryThis PR fixes a real correctness issue in ClickHouse Rules
Final Verdict
|
LLVM Coverage Report
Changed lines: 100.00% (6/6) · Uncovered code |
1b38da3
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix server crash (SIGABRT) when using aggregate functions with the internal-only
Nullcombinator (e.g.sumNull,avgNull) andaggregate_functions_null_for_empty = 1setting enabled.What this PR fixes
In
rewriteAggregateFunctionNameIfNeeded()(QueryAnalyzer.cpp:950), the code callstryGetProperties()and immediately dereferences the returnedstd::optionalwithout checking if it has a value:tryGetProperties()returnsnulloptfor functions using the internal-onlyNullcombinator. TheNullcombinator passesisAggregateFunctionName()(which doesn't checkisForInternalUsageOnly()) but failstryGetProperties()(which does check). Whenaggregate_functions_null_for_empty = 1, this path is entered and the dereference of an empty optional callsstd::abort()→ SIGABRT (signal 6).The correct pattern is already used 12 lines below (line 962) for the same
tryGetProperties()call:if (function_properies && !function_properies->returns_default_when_only_null)Reproduction
After fix: returns error Code 63
UNKNOWN_AGGREGATE_FUNCTION("Aggregate function combinator 'Null' is only for internal usage").CI impact
This crash was hitting BuzzHouse CI on master and 12+ unrelated PRs across multiple build types (amd_tsan, arm_asan_ubsan, amd_debug, amd_msan) since 2026-03-22:
Test
Added regression test
04068_aggregate_null_for_empty_with_null_combinatorthat verifies the server returns a proper error instead of crashing. Passes 50/50 with full randomization.Version info
26.4.1.420