Skip to content

Fix double free when finalizing -State aggregates under looping combinators - #111287

Merged
nihalzp merged 16 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-groupfnstate-combinator-double-free
Sep 22, 2026
Merged

nihalzp merged 16 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-groupfnstate-combinator-double-free

Conversation

@groeneai

@groeneai groeneai commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #110975

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixes a server crash (double free) when finalizing an aggregate function with the -State combinator nested under a combinator that transfers several sub-states in one call (-Resample, -ForEach, -Map, -Tuple), for example groupArrayStateResample, if an exception such as a memory limit is thrown part-way through the transfer.

Description

Found by CI on the PR linked above (unrelated to it): a segfault in Aggregator::prepareChunkAndFillWithoutKey, later the same defect as a use-after-dtor in Stress test (arm_msan).

Root cause: AggregateFunctionState::insertResultInto transfers ownership by aliasing the state pointer into a ColumnAggregateFunction, so the pointer briefly has two owners. Both aggregator entry points disambiguate positionally and so assume the transfer is atomic: on an exception they run a full destroy for the place that threw. A combinator transferring several sub-states in one call aliases child 0, then throws while transferring child 1, so child 0 is freed by the aggregator and again by ~ColumnAggregateFunction.

Change: atomicity is restored by undoing a partial transfer. A new IAggregateFunction::rollbackInsertResult(place, to) noexcept removes exactly the rows a matching insertResultInto appended, in reverse; -State pops its aliased row without destroying the state (new ColumnAggregateFunction::popBackWithoutDestroy); -Resample, -ForEach, -Map and -Tuple wrap their transfer loop and their own offsets append in a try that undoes the children whose transfer returned, restores their own bookkeeping and rethrows; the pass-through combinators forward. The undo path is entered only where a state is aliased, so nothing else changes behaviour. This replaces the previous reserveForInsertResult approach, which cannot close the window in general (ColumnString::chars cannot be pre-sized); that scaffolding is removed.

Validation: the stateless test drives the failure deterministically through two failpoints, one inside a partially transferred -State child and one at a -Tuple boundary whose predecessor transferred in full, and asserts the error code and finalized values over 13 chains. Twelve of them abort with an ASan double-free before the change and pass after it; the thirteenth is a control, a plain -State transfer being atomic already. Each of the seven undo bodies that is not a plain forward is load-bearing: reverting one alone to the base popBack(1) reddens a named chain.


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

Version info

  • Merged into: 26.10.1.407-master (included in 26.10 and later)
  • Backported to: 26.9.2.39, 26.8.11.53, 26.7.14.51, 26.3.33.157

groeneai and others added 2 commits July 21, 2026 20:20
…nators

A server crash (double free) happens when an aggregate function with the
-State combinator is nested under a looping combinator (-Resample, -ForEach,
-Map) and finalization hits a memory limit part-way through.

The -State combinator inserts its result by aliasing the raw aggregate state
pointer into a ColumnAggregateFunction (AggregateFunctionState::insertResultInto
-> ColumnAggregateFunction::getData().push_back(place)). Ownership of that state
is transferred to the column, and Aggregator::insertAggregatesIntoColumns relies
on this transfer being atomic per place: on an exception it destroys the whole
place exactly once.

A looping combinator breaks that atomicity. It aliases many sub-states into the
column one at a time inside a loop. The push_back into the column's pointer array
can reallocate and, being memory-tracked, throw MEMORY_LIMIT_EXCEEDED mid-loop.
At that point the sub-states inserted so far are already owned by the column, but
the aggregator's cleanup runs the combinator's full destroy() over every
sub-state, so the transferred ones are freed once by the aggregator and again by
~ColumnAggregateFunction. The reported crash was:

  SELECT arrayMap(x -> finalizeAggregation(x), state)
  FROM (SELECT groupArrayStateResample(0, 1048576, 1)(number, number % 20) AS state
        FROM numbers(...))

crashing in ~GroupArrayNumericData -> PODArray::dealloc from
~ColumnAggregateFunction, reached via Aggregator::prepareChunkAndFillWithoutKey.

Fix: reserve the destination columns before the transfer loop so the aliasing
push_backs cannot reallocate (and therefore cannot throw) once a transfer has
started. ColumnAggregateFunction previously used the no-op IColumn::reserve, so a
real reserve() (and matching capacity()) is added for its state-pointer array.
For -Map, the (possibly variable-width) key inserts are moved into their own loop
before the value transfer, keeping all throwing work out of the aliasing loop.
Reserving happens before any aliasing, so a throw there is harmless.

The transfer loop is now non-throwing at the point of aliasing, restoring the
atomic-per-place contract; results are unchanged. All three looping combinators
share the same aliasing path (AggregateFunctionState::insertResultInto ->
insertResultIntoImpl -> Aggregator::insertAggregatesIntoColumns), so the fix is
applied to all three. The added stateless test reproduces the crash deterministically
via -Resample (empty buckets keep memory low until the finalization transfer, so a
memory limit reliably lands the throw mid-transfer); -ForEach and -Map build their
sub-states eagerly during aggregation and are not deterministically reproducible
under a memory limit, but are fixed as the same class.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. groupArrayStateResample(0, 1048576, 1) over numbers(100000) at max_memory_usage=150MB crashes the server every time on master.
b Root cause explained? Yes. -State aliases each sub-state pointer into a ColumnAggregateFunction via push_back; a looping combinator does this in a loop. A mid-loop realloc throws MEMORY_LIMIT_EXCEEDED; Aggregator::insertAggregatesIntoColumns then runs the throwing function's full destroy() over sub-states already transferred to the column, which ~ColumnAggregateFunction frees again -> double free.
c Fix matches root cause? Yes. Reserving the destination before the loop makes the aliasing push_backs non-throwing, restoring the atomic-per-place transfer contract the aggregator relies on.
d Test intent preserved / new test added? New stateless test 04614_group_array_state_resample_finalize_no_crash added; asserts the server survives the memory-limited finalization and returns correct results.
e Both directions demonstrated? Yes. Pristine master: test crashes (SIGSEGV, exit 210, empty output = FAIL). With fix: server survives 20/20, output matches reference = PASS.
f General, not a narrow patch? Yes. All three looping transfer combinators (-Resample, -ForEach, -Map) share the aliasing path (AggregateFunctionState::insertResultInto -> insertResultIntoImpl -> Aggregator::insertAggregatesIntoColumns); the fix is applied to all three. Non-looping combinators delegate one call and are already atomic.
g Generalizes across inputs? The -Resample path is deterministically reproduced. -ForEach/-Map build sub-states eagerly during aggregation, so a memory-limited crash is not deterministically reproducible for them, but they are fixed as the same class via the shared transfer path. The merge path is unaffected (it creates its own states and does not alias).
h Backward compatible? Yes. reserve() is a capacity hint; no on-disk/wire/setting change; results are byte-identical.
i Invariants preserved? Yes. Restores the atomic-per-place transfer contract in insertAggregatesIntoColumns. The new ColumnAggregateFunction::reserve()/capacity() only pre-size the pointer array. Merge path (insertMergeResultInto) is untouched in behavior.

Session id: cron:clickhouse-author-slot-1:20260721-190200

@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review — adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 3 findings across 1 full pass + 1 delta recheck; bounded).

# Sev Finding Verdict Evidence / action
1 ⚠️ Regression test did not actually exercise the -ForEach failure mode (its -ForEach case had fan-out 2 — 1048576 is the groupArray size param, not the ForEach width) and had no -Map case; loop markers were discarded so it could pass without hitting the memory limit. AGREE Verified on the pristine binary: the -ForEach/-Map cases could not be made to fail-without-fix (they build sub-states eagerly during aggregation). Rewrote the test to the single DETERMINISTIC -Resample case, proven both directions (pristine: SIGSEGV / exit 210 / empty output = FAIL; fixed: matches reference = PASS). -ForEach/-Map are fixed as the same class via the shared transfer path (documented in the commit message + PR body), not a misleading test.
2 💡 The same double-free explanation was repeated across four verbose comment blocks. AGREE Trimmed all four to one-line local invariant notes pointing at AggregateFunctionResample.h; moved the mechanism explanation to the commit message.
3 💡 Test comment did not backtick literal identifiers (-State, ColumnAggregateFunction, MEMORY_LIMIT_EXCEEDED, ...). AGREE Backticked the literals (repo convention; comment-only).

Severity: ❌ blocker / ⚠️ major / 💡 nit. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-author-slot-1:20260721-190200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @nihalzp — could you review this? It fixes a double free during aggregate finalization: a -State function under a looping combinator (-Resample/-ForEach/-Map) aliases sub-state pointers into a ColumnAggregateFunction in a loop, and a mid-loop MEMORY_LIMIT_EXCEEDED from the pointer-array realloc makes Aggregator::insertAggregatesIntoColumns re-destroy the already-transferred states. The fix reserves the destination before the loop so the aliasing transfer is non-throwing.

(@alexey-milovidov is already tracking this from #110975, where the crash was reported.)

@pufit pufit added the can be tested Allows running workflows for external contributors label Jul 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cb562bc]

Summary: ✅


AI Review

Summary

This PR replaces the earlier reservation-based fix with an explicit rollback contract for state-producing aggregate finalization. The current implementation now restores partial transfers in the looping combinators, forwards rollback through the transparent wrappers, and gives -State the one special undo path it needs to avoid destroying aliased states. I did not find a remaining correctness gap in the current diff, and the new stateless test exercises both the partially transferred child case and the completed-child rollback case.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit cb562bc.

Metric Baseline Current Δ
Lines 88.50% 88.50% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.80% 80.80% +0.00%

Changed lines: Changed C/C++ lines covered: 204/231 (88.31%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 21, 2026
Comment thread src/Columns/ColumnAggregateFunction.h Resolved
@nihalzp nihalzp self-assigned this Jul 21, 2026
…t wrappers

The -Tuple combinator transfers each element's result into its own subcolumn one
element at a time. When an element is a -State aggregate (directly, or under a
looping or transparent combinator), that transfer aliases the state pointer into a
ColumnAggregateFunction. If a later element's transfer then throws (for example a
memory limit hit while a nested -Resample element reserves its buckets),
Aggregator::insertAggregatesIntoColumns runs the -Tuple function's full destroy()
over every element, so the already-aliased earlier element is freed by the
aggregator and again by ~ColumnAggregateFunction: a double free.

Add a reserveForInsertResult() hook so all destination capacity is reserved before
any element is transferred:
  - State reserves its ColumnAggregateFunction slot;
  - the looping combinators (-Resample/-ForEach/-Map) reserve their nested columns;
  - -Tuple calls it on every element before transferring any of them;
  - the transparent combinators that delegate insertResultInto to a nested function
    (-If/-Array/-Distinct/-Merge/-OrFill/-Null/-ArgMin/-ArgMax) forward the hook, so
    a -State element reachable through them is reserved too.
Once the reservations are done, transferring the first element cannot be followed by
a throwing reservation while transferring a later element.

Reproducers (crashed before, clean MEMORY_LIMIT_EXCEEDED after), with
max_threads = 1, max_memory_usage = 285000000:
  SELECT groupArrayStateResampleTuple(0, 1048576, 1)((number, number + 1), (number % 20, number % 20)) FROM numbers(100000)
  SELECT groupArrayStateResampleIfTuple(0, 1048576, 1)((number, number + 1), (number % 20, number % 20), (number > 0, number > 0)) FROM numbers(100000)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review trail (click to expand)

Independent code review (2 rounds) of the -Tuple extension. Adjudication:

# Finding Verdict Resolution
1 -Tuple pre-reserve missing / one-liner insufficient AGREE Reproduced the crash; the reserve(size+1) one-liner does not cover a looping-combinator element. Added the reserveForInsertResult() hook (State + Resample/ForEach/Map + Tuple pre-pass).
2 Nullable wrapper reopens the window DISAGREE (evidence) Not reachable for a -State result: canBeInsideNullable()==false + -Null redirected inside -State, so the null-map branch is compile-time excluded and the CAF is never the nullable to.
3 Transparent wrappers (-If/-Array/-Distinct/-Merge/-OrFill/-ArgMin/-ArgMax) don't forward the hook AGREE Reproduced groupArrayStateResampleIfTuple crash. Forwarded reserveForInsertResult() through all of them; added the -If case to the test.
4 Nested-cumulative reserve (e.g. -ForEach inside -Resample) PARTIAL / pre-existing This deep-expanding gap pre-exists in the merged single-column reserve fix (reproducible neither in nor out of Tuple in extensive sweeps). Each combinator reserves its direct columns (exact for the -State leaf, the reproduced class); not fixed speculatively here.
5 Map string-key chars not reserved PARTIAL / pre-existing Same class as #4 (ColumnString::reserve reserves offsets only); the -State value-aliasing window (the actual double-free) is closed.
6 Test didn't assert MEMORY_LIMIT_EXCEEDED; unpinned settings AGREE Pinned max_threads=1, assert the limit was hit for each loop.

Verification: both named reproducers 50/50 clean MEMORY_LIMIT_EXCEEDED (0 crashes), correctness unchanged across the combinator family, Build-ID verified.

The regression test asserted a fixed absolute memory limit (150MB/285MB)
tripping MEMORY_LIMIT_EXCEEDED via 'seen_limit' echoes. Whether a query
crosses a fixed byte limit is not portable across sanitizers (ASan/MSan/TSan
shift memory accounting), so the flaky check failed deterministically on all
three sanitizers with 'result differs with reference'.

Drop the threshold-dependent assertions; keep the crash-driving finalization
loops (which crash an unfixed server) but discard their output and assert only
the deterministic tail (server survived, correct results), like
01302_aggregate_state_exception_memory_leak. The loops now sweep a small range
of memory limits per combinator family so the throw still lands mid-transfer on
an unfixed server regardless of sanitizer.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixed the flaky-check failure on the new regression test 04614_group_array_state_resample_finalize_no_crash (pushed 64790d9).

Root cause: the test asserted a fixed absolute memory limit (150MB/285MB) tripping MEMORY_LIMIT_EXCEEDED via seen_limit echoes. Whether a query crosses a fixed byte limit is not portable across sanitizers (ASan/MSan/TSan shift memory accounting), so the flaky check failed deterministically on all three with "result differs with reference" (resample tuple hit memory limit was 0 instead of 1 under the sanitizer).

Fix (test only, source unchanged): drop the threshold-dependent assertions; keep the crash-driving finalization loops (they still crash an unfixed server) but discard their output and assert only the deterministic tail (server survived, correct results), the same shape as 01302_aggregate_state_exception_memory_leak. Verified both directions on the pre-fix vs fixed binary: pre-fix SIGSEGVs on all three combinator families (Resample / ResampleTuple / ResampleIfTuple), fixed build survives; the tail output is byte-stable across 10 runs.

@clickhouse-gh

clickhouse-gh Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 80.40% 86.20% +5.80%
Functions 91.50% 92.00% +0.50%
Branches 72.30% 78.20% +5.90%

Changed lines: Changed C/C++ lines covered: 60/82 (73.17%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 64790d9

Every failure below has an owner. None are PR-caused: the PR's own test 04614_group_array_state_resample_finalize_no_crash failed the .reference diff only on the earlier commit 43ce5e35 (expected resample tuple hit memory limit values were stale); the subsequent test-only commit 64790d9 updated the reference and those checks (arm_binary, sequential + all four flaky-checks) are green on this head.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) / test_check_table::test_check_all_tables chronic flaky (154 hits / 119 PRs / 15 master, 30d) a fix task is moved to pending (investigating at full effort; fixing-PR link to follow here)
Stateless (amd_llvm_coverage, ParallelReplicas, s3, parallel) / Logical error '!part.empty()' (STID 5217-505b) + Server died chronic trunk parallel-replicas "unknown stream"/"unknown stream" reading-coordinator crash (34 PRs / 0 master, 30d) a fix task is moved to pending (investigating at full effort; fixing-PR link to follow here)
Mergeable Check / PR rollup of the above owned via the two lines above

Session id: cron:our-pr-ci-monitor:20260722-113000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the test_check_all_tables flaky (Integration amd_asan_ubsan, db disk, old analyzer): #111353 (merged 2026-07-22, backported to 26.7 by #111574).

The failure is the plain-rewritable metadata_dropped concurrent-create race, not anything in this PR. Every occurrence after that merge is on a build whose base predates it: I checked all 49 distinct commits that produced this failure since 2026-07-22 17:31Z, and 49 of 49 lack the fix. Merging master into this PR picks it up. Details: #111477 (comment)

…e-free

Master added getArgumentsThatCanBeOnlyNull overrides to the ArgMin/ArgMax and
Resample wrappers at the same anchor this branch uses for its
reserveForInsertResult overrides, so both files conflicted textually. The two
methods are independent, and both sides are kept.

The Resample pre-reservation call still runs before the per-bucket aliasing
transfer loop, which is the property the fix depends on. The merged tree differs
from master by exactly the 17 files of this pull request, with no submodule
pointer drift.
Earlier review rounds answered each challenge by writing the justification into
the source, and nothing removed those lines again, so the comments had ratcheted
up to nine consecutive lines in one block. Each comment now states only the local
invariant a reader needs at that spot. The mechanism, the reachability evidence
for each combinator, and the alternatives that were ruled out live in the earlier
commit messages and in the pull request discussion instead.

No functional change.
`AggregateFunctionOrFill::reserveForInsertResult` forwarded the reserve only when
`insertResultInto` transfers into `to` itself. In the complementary branch
(`result_is_nullable && !inner_nullable`) it was a complete no-op, although
`insertResultIntoImpl` does transfer there too, into `col.getNestedColumn()`.

`DataTypeAggregateFunction::canBeInsideNullable()` is false, so a bare `-State`
result is never wrapped in `Nullable` and that branch is unreachable for it. But
`DataTypeTuple::canBeInsideNullable()` is true, so `createResultType` does wrap a
Tuple-of-States: `sumStateTupleOrNull((1,2))` is
`Nullable(Tuple(AggregateFunction(sum, UInt8), ...))`.

A single `-OrNull` frame is still safe, because it appends the null-map entry
before the nested transfer. The window opens one level up. `-Resample`,
`-ForEach` and `-Map` pre-reserve their destination with the generic
`IColumn::reserve`, which recurses through `ColumnNullable` (nested column plus
null map) and `ColumnTuple` (every element), so a nullable wrapper under them is
covered. `AggregateFunctionTuple::insertResultIntoImpl` instead pre-reserves by
asking each element function, so for an `-OrNull` element nothing was reserved:
the second element's transfer could reallocate the destination after the first
had already aliased a `-State` pointer into it, and the aggregator's cleanup then
destroyed states the result column destroys again.

Measured on a debug build with
`groupArrayStateResampleTupleOrNullTuple(0, 1048576, 1)(...)` over `numbers(100000)`
at `max_threads=1`: `max_memory_usage=360000000` segfaulted 3/3 in
`ColumnAggregateFunction::~ColumnAggregateFunction` before this change and reports
`MEMORY_LIMIT_EXCEEDED` 3/3 after it, with 340000000/380000000/400000000 unchanged
in both directions. `-OrDefault`, the same class with `result_is_nullable` false,
is clean 8/8 on both binaries, which attributes the crash to the skipped branch
rather than to the query shape. `-ForEach` over a `Null`-adapted Tuple-of-State is
also clean before the change, as the generic-reserve reading predicts.

`AggregateFunctionNull::reserveForInsertResult` has the same shape, but for an
element of an outer `-Tuple` the `-State` redirect in the `Null` combinator moves
the nullability into the argument type rather than the result, so no
`ColumnAggregateFunction` sits under a nullable `to` there. It is left unchanged.
`AggregateFunctionNullBase::reserveForInsertResult` had the same shape as the
`-OrNull` hook fixed in the previous commit: it forwarded the reserve only in the
non-nullable instantiation, although `insertResultIntoImpl` also transfers in the
nullable one, into `to_concrete.getNestedColumn()`, and appends the null-map entry
after that transfer rather than before it.

The previous commit's reasoning for leaving this alone was wrong. It only covered
the `-State` redirect in the `Null` combinator, which moves the nullability into
the argument type for an element of an outer `-Tuple`. A `Nullable(Tuple(...))`
argument reaches the adapter directly, and then the result really is
`Nullable(Tuple(AggregateFunction(...)))`:
`sumStateTupleDistinctTuple(CAST(..., 'Tuple(Nullable(Tuple(UInt8, UInt8)), ...)'))`
under `enable_nullable_tuple_type`.

Measured with `groupArrayStateResampleTupleDistinctTuple(0, 1048576, 1)` over
`numbers(100000)` at `max_threads=1` and `max_memory_usage=360000000`: segfault 3/3
in `ColumnAggregateFunction::~ColumnAggregateFunction` without this change,
`MEMORY_LIMIT_EXCEEDED` 3/3 with it. Reverting either hook in isolation reddens
only its own query and leaves the other passing, so the two are independently
needed.

`-ForEach` over the same adapter is clean before either change, because the looping
combinators pre-reserve their destination with the generic `IColumn::reserve`, which
recurses through `ColumnNullable` and `ColumnTuple`. Only
`AggregateFunctionTuple::insertResultIntoImpl`, which pre-reserves by asking each
element function, could observe a wrapper that reserved nothing.
@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing cb562bc61 with master 694b427f0 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes.

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 ⚠️

159 object files changed (+1.36 MiB total), 0 added.

Object file Master PR Δ
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsNumericIndexedVector.cpp.o 33.39 MiB 33.70 MiB +314.93 KiB (+0.92%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniq.cpp.o 10.93 MiB 10.99 MiB +65.04 KiB (+0.58%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionCovar.cpp.o 6.40 MiB 6.45 MiB +49.15 KiB (+0.75%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionCorr.cpp.o 6.58 MiB 6.63 MiB +48.86 KiB (+0.73%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionGroupArrayMov… 5.73 MiB 5.77 MiB +43.20 KiB (+0.74%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionGroupNumericI… 7.19 MiB 7.23 MiB +43.05 KiB (+0.58%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/Combinators/AggregateFunctionM… 1.56 MiB 1.59 MiB +37.71 KiB (+2.37%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSum.cpp.o 3.48 MiB 3.50 MiB +30.05 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.82 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.82 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.82 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined2… 2.89 MiB 2.91 MiB +24.82 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.92 MiB +24.82 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.82 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.81 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.81 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniqCombined1… 2.89 MiB 2.91 MiB +24.81 KiB (+0.84%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/Combinators/AggregateFunctionD… 1.49 MiB 1.51 MiB +22.44 KiB (+1.47%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionAvgWeighted.c… 12.79 MiB 12.81 MiB +21.89 KiB (+0.17%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionQuantileExact… 2.92 MiB 2.94 MiB +20.85 KiB (+0.70%)

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

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

Job report

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 62ffd58

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task of mine
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 04561_ie_join_storage_join test defect, not a product regression: the test's two serverError INCOMPATIBLE_TYPE_OF_JOIN assertions and its not-routed count do not hold under the ParallelReplicas parametrization, so they invert together (deterministic, 3 of 3 reruns) #113840 (external, merged 2026-08-07T20:50:30Z)

157 of 175 checks succeeded, 17 skipped, 1 failed. Finish Workflow and Config Workflow both succeeded.

The failing test is not part of this branch: it was added to master earlier today and reaches CI
through the auto-recomposed refs/pull/111287/merge tree. The master parent of the tree that ran
(1c39bbe4e7df) is 154 commits behind #113840's merge commit, and the test file in that tree is
byte-identical to the pre-fix revision, so this build predates the fix. No branch merge is needed
here: the merge tree is recomputed against master, so the next run of this job picks the fix up on
its own.

Session id: cron:our-pr-ci-monitor:20260807-233000

Master's only churn on this branch's files since the previous merge is
037ef93 "Revert \"Add aggregate function gini\"", which removes the
getArgumentsThatCanBeOnlyNull() overrides that the previous merge had kept
alongside this branch's reserveForInsertResult() hooks. Seven of this
branch's seventeen files drifted; five auto-merged and two conflicted
(AggregateFunctionResample.h, AggregateFunctionCombinatorsArgMinArgMax.cpp),
in both cases because master deleted the override at the same anchor where
this branch adds the reserve hook.

Resolution keeps the reserve hook and takes master's deletion, matching what
the five auto-merged files did. The two hunks are orthogonal: they override
different base virtuals declared independently in IAggregateFunction.h, which
master did not touch.

Verified: no conflict markers; the merged tree differs from master in exactly
the seventeen files of this branch and in zero submodule gitlinks; and for all
seventeen the md5 of this branch's added-plus-removed lines is unchanged before
and after the merge. The Resample pre-reservation remains ahead of the aliasing
loop in insertResultIntoImpl.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 203ce57

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3) / 04509_hash_table_sizes_stats_table_functions prealloc reported 0 instead of 650000/520000; process-wide HashTablesStatistics singleton gets sized to zero capacity by whichever caller arrives first, so every entry is admitted then instantly evicted #114597 (external, open)
Stress test (arm_debug) / Logical error: Not-ready Set is passed as the second argument for function 'globalNotNullIn' (STID 0250-4e52) in-place set build fails and leaves the subquery plan unrestored #102308 (external, open)

Neither failure is in this PR's diff, which is confined to src/AggregateFunctions/Combinators/,
IAggregateFunction.h and ColumnAggregateFunction.h. 04509 is a low-rate flake, not a
regression: on master over the last 3 days it is 3 failures against roughly 600 passes.

Session id: cron:our-pr-ci-monitor:20260813-183000

@groeneai

Copy link
Copy Markdown
Collaborator Author

The failure was on the previous head 3c8255b4b5b0 (Build (arm_tidy), 2026-09-18 23:49Z). That job log contains exactly one error, and it is not in this PR:

/ClickHouse/src/Core/tests/gtest_settings.cpp:16:1: error: duplicate include [readability-duplicate-include,-warnings-as-errors]

This PR touches 20 files (src/AggregateFunctions/Combinators/*, IAggregateFunction.h, ColumnAggregateFunction.{h,cpp}, FailPoint.cpp, one stateless test). gtest_settings.cpp is not one of them, and the log has no clang-tidy diagnostic in any file the PR does change.

It came from master, as a merge artifact of my own #118612: both parents of its merge commit b18ca9e7ec33 carry exactly one #include <IO/VarInt.h> (master at line 11, the branch at line 14), so the textual merge produced two and neither side's own CI could see it. In CIDB the same diagnostic failed Build (arm_tidy) on 53 distinct PRs between 17:03Z and 00:27Z. It was reverted in #120930 (merged 23:19:51Z).

I merged that revert into this PR at 04:51Z. On the current head 966f5e709312, Build (arm_tidy) went green at 05:24:24Z, 41 seconds after your comment, so the rollup you were reading was still the old head. That head has no failures so far: 37 success, 8 skipped, 12 still running.

@nihalzp
nihalzp added this pull request to the merge queue Sep 22, 2026
Merged via the queue into ClickHouse:master with commit 6c2fec3 Sep 22, 2026
177 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 22, 2026
@nihalzp nihalzp added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 24, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 24, 2026
PedroTadim added a commit that referenced this pull request Sep 25, 2026
Cherry pick #111287 to 26.3: Fix double free when finalizing -State aggregates under looping combinators
PedroTadim added a commit that referenced this pull request Sep 25, 2026
Cherry pick #111287 to 26.7: Fix double free when finalizing -State aggregates under looping combinators
PedroTadim added a commit that referenced this pull request Sep 25, 2026
Cherry pick #111287 to 26.8: Fix double free when finalizing -State aggregates under looping combinators
PedroTadim added a commit that referenced this pull request Sep 25, 2026
Cherry pick #111287 to 26.9: Fix double free when finalizing -State aggregates under looping combinators
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
robot-clickhouse added a commit that referenced this pull request Sep 25, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 25, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 25, 2026
Backport #111287 to 26.9: Fix double free when finalizing -State aggregates under looping combinators
clickhouse-gh Bot added a commit that referenced this pull request Sep 25, 2026
Backport #111287 to 26.8: Fix double free when finalizing -State aggregates under looping combinators
clickhouse-gh Bot added a commit that referenced this pull request Sep 25, 2026
Backport #111287 to 26.7: Fix double free when finalizing -State aggregates under looping combinators
PedroTadim added a commit that referenced this pull request Sep 25, 2026
Backport #111287 to 26.3: Fix double free when finalizing -State aggregates under looping combinators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR groeneai-origin-review-human PR origin: human review feedback on a groeneai PR pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

6 participants