Repository navigation
Fix arrayFold LOGICAL_ERROR over non-const Array(LowCardinality(T)) - #109462
alexey-milovidov merged 2 commits into
Conversation
In FunctionArrayFold::executeImpl, the non-const branch passed the nested
data column to the lambda as array_col_concrete->getDataPtr() (the raw
LowCardinality column) while stripping LowCardinality from its type via
recursiveRemoveLowCardinality. The column and type then diverged: a
LowCardinality column carrying a non-LowCardinality type.
When the lambda body's binary function (e.g. plus) resolved to a
non-LowCardinality result, the default LowCardinality function adaptor did
not unwrap the argument, so the function received a LowCardinality column
dispatched as its plain type and threw LOGICAL_ERROR ("Arguments of 'plus'
have incorrect data types") - a server abort in debug and sanitizer builds.
The const branch already avoided this by calling
recursiveRemoveLowCardinality(...->convertToFullColumn()) on the column.
Strip LowCardinality from the nested data column in lockstep with its type
on the non-const path too. recursiveRemoveLowCardinality is a no-op for
non-LowCardinality columns and recurses through wrappers, so nested cases
such as Array(LowCardinality(Nullable(T))) are covered as well.
Found by the AST fuzzer (Stress test (arm_msan), STID 2735-474b).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260706-023700 |
|
cc @rschu1ze @Avogar — could you review this? It fixes an |
|
Workflow [PR], commit [4523b99] Summary: ✅
AI ReviewSummaryThis PR fixes Final Verdict✅ No new findings in the current diff. |
CI finish ledger — c68ee1aNone of the failures are caused by this PR (the diff only touches
Session id: cron:our-pr-ci-monitor:20260706-153000 |
|
Fixing PR for the Stress-test TSan Correction to the finish-ledger line above: STID 1464-2f74's write-of-size-8 stack is |
|
Ledger follow-up for the Investigated as a full-effort owner. This is a proven ultra-rare non-reproducible transient on the slow msan/WasmEdge lane, unrelated to this PR (diff only touches
Not a randomized-setting interaction (pinning would not help) and not reproducible, so no code change or setting pin is warranted. No fixing PR needed for this line. |
|
@groeneai merge with master. Also analyze the unrelated failures, especiallt crashes in ast fuzzers and create issues/fixes |
…nst-lowcardinality
|
Merged fresh master (branch head Analyzed the unrelated failures on the previous run. All three AST-fuzzer crashes were re-verified to still reproduce on current master, and each now has a public issue + fix:
The segfault (1719-3ae5) had a fix PR but no public issue, so I opened #109682 with the reproducer, stack, and root cause. Non-fuzzer unrelated failures: TSan data race in uniqExact two-level merge (1464-2f74) fixed by merged #109389; |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 3/3 (100.00%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This is a narrow fix to arrayFold's LowCardinality unwrapping (column stripped in lockstep with the type); no ClickBench query uses arrayFold, so none of the flagged deltas can plausibly be caused by the PR. The two flagged improvements, Q4 (-13.5%) and Q15 (-19.8%), fall inside master's normal variance band and were correctly suppressed to no_change. The three borderline +5% increases on Q28/Q33/Q34 are test-disagreement not_sure calls that, given the off-path diff, are run-to-run variance. Net: no real performance impact expected from this change. clickbenchFlagged queries (3 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_official🟢 No significant changes Debug info
|
Pull in the `arrayFold` `LowCardinality` `LOGICAL_ERROR` fix from #109462 (commit c68ee1a), which resolves the pre-existing `AST fuzzer (amd_debug)` failure on this branch: `Arguments of '...' have incorrect data types` raised via `arrayFold.cpp:291` -> `ColumnFunction::reduce` on the non-const `Array(LowCardinality(T))` path. That failure was previously mis-tracked as #109682 (a distinct `SIGSEGV` in `removeNullable` via `FunctionArrayMapped`). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…onst-lowcardinality Fix arrayFold LOGICAL_ERROR over non-const Array(LowCardinality(T))
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERRORinarrayFoldover a non-constArray(LowCardinality(T))argument (for examplearrayFold((acc, x) -> acc + x, materialize([1, 2, 3]::Array(LowCardinality(Int64))), toInt64(0))), which failed with "Arguments of 'plus' have incorrect data types" (a server abort in debug and sanitizer builds).Description
Found by the AST fuzzer:
Stress test (arm_msan), STID2735-474b, e.g. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109085&sha=2e6b5fbdcbf4ff2a37ec0c006d3775d15bd695f6&name_0=PR&name_1=Stress%20test%20%28arm_msan%29Root cause: in
FunctionArrayFold::executeImpl, the non-const branch built the nested data column passed to the lambda asarray_col_concrete->getDataPtr()(the rawLowCardinalitycolumn) while strippingLowCardinalityfrom its type viarecursiveRemoveLowCardinality. The column and type then diverged: aLowCardinalitycolumn carrying a non-LowCardinalitytype. When the lambda body's binary function (e.g.plus) resolved to a non-LowCardinalityresult, the defaultLowCardinalityfunction adaptor did not unwrap the argument, so the function received aLowCardinalitycolumn dispatched as its plain type and raisedLOGICAL_ERROR. The const branch already avoided this by callingrecursiveRemoveLowCardinality(...->convertToFullColumn())on the column too.Fix: unwrap
LowCardinalityfrom the nested data column in lockstep with its type on the non-const path.recursiveRemoveLowCardinalityis a no-op for non-LowCardinalitycolumns and recurses through wrappers, so nested cases likeArray(LowCardinality(Nullable(T)))are covered as well.Version info
26.7.1.805(included in26.7and later)