Skip to content

Keep the function name of a stack frame attributed to a libc++ __functional header - #112152

Merged
alexey-milovidov merged 20 commits into
masterfrom
fix-stacktrace-functional-name-suppression
Aug 13, 2026
Merged

alexey-milovidov merged 20 commits into
masterfrom
fix-stacktrace-functional-name-suppression

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Caused by: #57201
Related: #100419

collapseDemangledNames replaced a stack frame's function name with ? whenever the frame's source location was a file in a directory ending in functional. The intent was to hide std::function plumbing frames, whose demangled names spell out the whole captured lambda type and say nothing the neighbouring frames do not already say.

But the file of a frame is the source line the instruction maps to, which is not necessarily where the enclosing function is defined. An ordinary function can have individual instructions attributed to a libc++ __functional header - an inlined std::function operation, or compiler-generated code reported with line 0 - and then its name was dropped too, which loses the only useful part of the frame.

This PR requires the symbol to name the std::function plumbing as well: the type-erasing wrappers (std::__function::__func, __value_func, __policy_func, ...) and the type erasure of std::function itself - its operator(), its copy, move and callable-taking constructors and assignment operators, and its destructor. The ordinary members of std::function (swap, target_type, operator bool, the nullptr reset operator=(std::nullptr_t), the empty-constructing function() / function(std::nullptr_t), ...) do work of their own, so they keep their names too. Those are still displayed as ?, exactly as before; every other frame keeps its name - not only an ordinary DB function, but also a meaningful libc++ symbol that happens to live in a __functional header, such as std::hash<String>::operator() from __functional/hash.h, or the generic invocation helpers std::invoke / std::__invoke / std::mem_fn, which are not std::function-specific and whose frames can name the callable they dispatch to.

This is much more likely in a build with ThinLTO enabled, where std::function calls are inlined across translation units, so it went unnoticed for a long time: amd_cfi is the only integration-test build with ThinLTO on, and its test_crash_log failure is what surfaced it. In that build, the frame that actually terminated the server was displayed as

8. contrib/llvm-project/libcxx/include/__functional/function.h:0:7: ? @ 0x1c01f41f

both in the fatal log and in trace_full in system.crash_log, where 0x1c01f41f is inside DB::executeQuery (the symbol resolves correctly - only the display suppressed it). Official release builds also use ThinLTO, so the same frames were being anonymised for users.

collapseDemangledNames becomes a static member of StackTrace so that the heuristic is covered by a unit test in every build, rather than only by the weekly ThinLTO job.

Fixes test_crash_log/test.py::test_crash_log_extra_fields[terminate_with_exception-trace_full] and [terminate_with_std_exception-trace_full], seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=b05161aa67d75ad84151a392f3e87156efd42842&name_0=WeeklyCFI&name_1=Integration%20tests%20%28amd_cfi%2C%202%2F4%29

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):

Fixed a stack frame being displayed as ? instead of its function name in fatal log messages and in the trace_full column of system.crash_log. It affected frames of ordinary functions that have code attributed to a libc++ __functional header, which is common in release builds.

Version info

  • Merged into: 26.8.1.1334 (included in 26.8 and later)
  • Backported to: 26.7.4.44, 26.6.3.58, 26.5.7.57

…l` header

`collapseDemangledNames` replaced a frame's name with `?` whenever the frame's
source location was a file in a directory ending in `functional`. The intent was
to hide `std::function` plumbing frames, whose demangled names spell out the whole
captured lambda type and say nothing the neighbouring frames do not already say.

But the file of a frame is the source line the *instruction* maps to, which is not
necessarily where the enclosing function is defined. An ordinary function can have
individual instructions attributed to a libc++ `__functional` header - an inlined
`std::function` operation, or compiler-generated code reported with line 0 - and
then its name was dropped too, which loses the only useful part of the frame.

Require the symbol to be a libc++ one as well. `std::function` trampolines are
still displayed as `?`, exactly as before; an ordinary function keeps its name.

This is much more likely in a build with ThinLTO enabled, where `std::function`
calls are inlined across translation units, so it went unnoticed: `amd_cfi` is the
only integration-test build with ThinLTO on, and its `test_crash_log` failure is
what surfaced it. In that build, the frame that actually terminated the server was
displayed as

    8. contrib/llvm-project/libcxx/include/__functional/function.h:0:7: ? @ 0x1c01f41f

in the fatal log and in `trace_full` in `system.crash_log`, where `0x1c01f41f` is
inside `DB::executeQuery`. Release builds also use ThinLTO, so the same frames were
being anonymised for users.

`collapseDemangledNames` becomes a static member of `StackTrace` so that the
heuristic is unit tested in every build, not only in the weekly ThinLTO job.

Fixes `test_crash_log/test.py::test_crash_log_extra_fields[terminate_with_exception-trace_full]`
and `[terminate_with_std_exception-trace_full]`, seen in
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=b05161aa67d75ad84151a392f3e87156efd42842&name_0=WeeklyCFI&name_1=Integration%20tests%20%28amd_cfi%2C%202%2F4%29
@clickhouse-gh

clickhouse-gh Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0fb79aa]

Summary: ✅


AI Review

Summary

The PR narrows StackTrace::collapseDemangledNames so only libc++ std::function type-erasure frames from __functional headers collapse to ?, while ordinary functions and meaningful libc++ helpers keep their names. The final matcher is consistent with the contract described in the PR, and the added gtest_stack_trace_collapse_names.cpp cases cover the regressions raised during review. I did not find a remaining correctness or evidence gap in the changed diff.

Final Verdict

✅ No review findings in the current diff.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.80% +0.10%
Functions 92.00% 92.00% +0.00%
Branches 79.10% 79.10% +0.00%

Changed lines: Changed C/C++ lines covered: 81/82 (98.78%) · 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 27, 2026
Comment thread src/Common/StackTrace.cpp Resolved
…g itself

The heuristic required the symbol to start with `std::`, which still dropped the
name of a meaningful libc++ frame that lives in a `__functional` header - libc++
puts `std::hash`, `std::less` and friends there too, so a crash inside
`std::hash<String>::operator()` was displayed as `?`.

Match the type-erasing wrappers of `std::function` and the invoke helpers they
forward through by name instead, and keep every other symbol named.
Comment thread src/Common/StackTrace.cpp Resolved
`std::__invoke`, `std::invoke`, and `std::__mem_fn` are generic C++
call wrappers, not `std::function`-specific plumbing, and their frames
can name the callable they dispatch to. Suppressing them recreated the
"lost the only informative frame name" bug for direct `std::invoke` /
`std::mem_fn` paths. Keep only the type-erasing wrappers of
`std::function` in the suppression set.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread src/Common/StackTrace.cpp Resolved
The `std::function<` prefix matched every member of `std::function`, so a
frame of `std::function<...>::swap`, `target_type` or `operator bool` was
still collapsed to `?` - the same "lose the only informative frame name"
bug, for that part of the surface.

Only the type erasure is noise: the call operator, the constructors and
the destructor, which copy, move and destroy the captured callable. The
member name is now read past the template argument list (nested `<`/`>`
of the callable's signature are counted) and matched against that list.

Adds `StackTraceCollapseNames.KeepsOrdinaryStdFunctionMembers` and cases
for the constructor and the destructor.
@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 67/68 (98.53%) · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (clean) and pushed 285d288c56f; both touched translation units (Common/StackTrace.cpp, Common/tests/gtest_stack_trace_collapse_names.cpp) compile clean against the merged tree.

The only blocker for Mergeable Check on the previous revision was BuzzHouse (amd_debug), which hit the known fuzzer Logical error: Pipeline stuck on a GenerateRandom + LIMIT insert — tracked in #106237 and unrelated to this change, which only affects how stack frame names are rendered.

@groeneai, please take a look at #106237 and provide a fix in a separate PR if one is not already in progress; link it there if it is.

Bugfix validation (unit tests) stays red by design: the overlaid gtest calls the newly exposed StackTrace::collapseDemangledNames, so it cannot compile against the before-binary, and the job reports that as inconclusive (ERROR), which does not block the merge.

Comment thread src/Common/StackTrace.cpp Resolved
@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

A fix is already in progress: #106251, open, waiting on one design decision about the memory bound of the queue-cap bypass. I have posted the current status on #106237.

Your attribution of the BuzzHouse (amd_debug) red on e8a322202b9a matches what I measured independently a day earlier from the full pipeline digraph in that job's server log (STID 3833-2f1a), so it is not caused by this PR.

…or frame

The constructor of `std::function` that takes a callable is a function
template, so after the outer `std::function<...>::` is stripped the member
is spelled `function<MyCallable, void>(MyCallable&&)`, which the
`function(` prefix did not match. Recognise `function<` as well, and add
the corresponding gtest case.
Comment thread src/Common/StackTrace.cpp Resolved
The callable-taking `operator=` overloads are function templates, spelled
`operator=<MyCallable, void>(MyCallable&&)` after the outer template argument
list is stripped, so they kept the whole captured type visible even though they
are the same type-erasing noise as the templated constructor. The copy and move
assignment (`operator=(`) do the same work as the copy and move constructors,
which were already hidden, so they are treated the same way. Regression cases
added to `HidesStdFunctionPlumbing`.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The two stress-test reds on 1fb14fd are unrelated to this rendering-only change:

@groeneai, investigate the Not-ready Set stress crash and provide a fix in a separate PR (if a fix or tracking issue is already in progress, link it here).

Comment thread src/Common/StackTrace.cpp Resolved
@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Investigated. The getMinMaxCountProjectionBlock sink is a distinct carrier from the one #107924 and #110198 fixed, so I am not linking either as the fix; a separate PR is coming.

What the stack shows. The failing thread is a mutation background task, not a query:

12. Functions/in.cpp:116                 FunctionIn::executeImpl  <- throws
19-21. Interpreters/ExpressionActions.cpp  ExpressionActions::execute
22-23. Storages/VirtualColumnUtils.cpp:162/753  filterBlockWithExpression / filterBlockWithPredicate
24. MergeTree/MergeTreeData.cpp:10111    getMinMaxCountProjectionBlock
25-26. optimizeUseAggregateProjection.cpp:630/846  getAggregateProjectionCandidates
31. Interpreters/MutationsInterpreter.cpp:291  isStorageTouchedByMutations
32-34. MutateTask::prepare / MutatePlainMergeTreeTask::executeStep

isStorageTouchedByMutations runs SELECT count() FROM <part> WHERE <mutation predicate>. When the table has an implicit minmax_count projection, optimizeUseAggregateProjections calls getMinMaxCountProjectionBlock, which filters the virtual-columns block through VirtualColumnUtils::filterBlockWithPredicate -> buildFilterExpression -> buildSetsForDAG. That is the unordered entry point (VirtualColumnUtils.cpp:95-98, /* ordered = */ false), which reaches FutureSetFromSubquery::buildSetInplace, not buildOrderedSetInplace.

Why the merged fixes do not cover it. #107924 rewrote buildOrderedSetInplace only: the clone-the-source non-destructive path, the temporary speculative_set, and the post-execute isCreated() check all live in that function. buildSetInplace still does the original auto plan = std::move(source) via build() and, crucially, has no isCreated() check after executor.execute() - so a pipeline that stops without calling Set::finishInsert leaves the set permanently unbuilt with source already consumed, and the next FunctionIn throws. #110198 stopped a cancelled build from poisoning the shared PreparedSetsCache and installed the mutation's interactive-cancel callback, but that callback is exactly what makes the unordered build stop early on this path, and buildSetInplace does not detect the stop. Both are ancestors of the failing build 51a976f2, so this is measured, not inferred.

The log supports that reading: two Code: 236 Cancelled merging parts at 00:02:30.566/.610, then the three Not-ready Set aborts at 00:02:30.832/.850/.917, one per mutating part of the same table (all_1_8_1_19, all_9_9_0_19, all_10_10_0_19).

Carrier. The table is test_3.test_filter__fuzz_0 (UUID 1cc10c2b), a fuzzed variant from 04305_mutation_in_subquery_column_identifier.sql, whose mutations are exactly ALTER UPDATE ... WHERE 1 IN (subquery) / DELETE ... WHERE exists(subquery).

Frequency. Over 45 days, 394 rows carry this message; only 2 have getMinMaxCountProjectionBlock in the stack (PR #107113 arm_release 2026-07-29, PR #109360 arm_asan_ubsan 2026-07-23) against 291 for the FilterTransform sink. Both minmax rows post-date the #110198 merge (2026-07-17). Rare, but it is a real server abort, and the 3-parts-at-once shape means one cancelled mutation takes the server down.

I could not reproduce it deterministically yet - the plain mutation-plus-IN shape and a transfer_overflow_mode = 'break' variant both pass on master, so the trigger needs the cancellation timing. #109722 is unrelated here: its diff is QueryPlan::clone / extractSubplan carrying max_threads, concurrency_control and resources, which only affects the buildOrderedSetInplace clone path.

Tracking issue for the family is #107619. I will open the PR for this sink and link it here.

@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Correction to my earlier comment, plus the actual root cause.

I was wrong about the trigger. I attributed the abort to the two Code: 236 Cancelled merging parts lines at 00:02:30.566/.610. Those carry query id 67393aab-514c-4d86-9e15-662c5175e16e and MergePlainMergeTreeTask, so they are a different table's merge, not this mutation. Of the 42 Cancelled merging parts lines in the log, zero belong to 1cc10c2b. The 1242 Code: 516 AUTHENTICATION_FAILED lines that do belong to it are retries and stop 1.3 s before the abort, so they are not the trigger either (an unreachable endpoint throws, and a throw leaves an ordinary failed mutation rather than an unbuilt set).

The trigger is DETACH DATABASE. Four lines, 311 ms:

00:02:30.521504 executeQuery: (from [::1]:50178) DETACH DATABASE test_3 (stage: Complete)
00:02:30.724898 test_3.test_filter (1cc10c2b-...): Start preparing for shutdown
00:02:30.823582 {1cc10c2b-...::all_1_8_1_19} StorageDistributed (remote): (127.0.0.1:9440) Cancelling query
00:02:30.832216 {1cc10c2b-...::all_1_8_1_19} Logical error: 'Not-ready Set is passed as the second argument for function 'in''

flushAndPrepareForShutdown (StorageMergeTree.cpp:282-290) calls merges_blocker.cancelForever(), which is what the interactive-cancel callback from #110198 (MergeTreeDataMergerMutator.cpp:502-507) tests. buildSetInplace feeds that callback to CompletedPipelineExecutor::setCancelCallback (PreparedSets.cpp:417-423), and execute (:93-95) then calls executor->cancel(). That stops the pipeline without throwing, so CreatingSetsTransform::generate and Set::finishInsert never run and isCreated() stays false. The remote leg is incidental: any cancel reproduces this with a purely local subquery.

Why this sink and not FilterTransform. The predicate is 1 IN (subquery), a constant left-hand side. tryPrepareSetIndexForIn returns at KeyCondition.cpp:2613 on indexes_mapping.empty() before reaching buildOrderedSetInplace, and the other ordered site (:985-988) is reuse-only. So the unordered build reached from getMinMaxCountProjectionBlock is the first and only materialization attempt.

Two defects, and neither is fixable alone.

  1. buildSetInplace has no post-execute readiness check and consumes source (build() at PreparedSets.cpp:379 does auto plan = std::move(source)). buildOrderedSetInplace got exactly this treatment in Fix "Not-ready Set" exception by making in-place set build non-destructive #107924; the unordered sibling did not.
  2. buildSetsForDAG returns void, so buildFilterExpression executes the DAG regardless, at both getMinMaxCountProjectionBlock and totalRowsByPartitionPredicateImpl.

Fixing only 2 relocates the exception rather than removing it: source is already gone, so makePlansForSets gets nullptr from build() and the same logical error fires at the FilterTransform sink instead.

This is already fixed in your own #102308. It adds hasUnbuiltSubquerySet and guards both MergeTreeData sites, and it rewrites buildSetInplace with createQueryPlanForRetry / restoreQueryPlanForRetry so a stopped build restores its source. That is both halves. #112968 separately turns buildSetsForDAG into bool all_sets_are_ready and guards the object-storage caller, which is the same defect class and the plumbing the general form wants.

So I would rather not open a third PR over buildSetInplace and those two call sites while both of yours are open. Which do you prefer:

  1. you rebase and un-draft Add a regression test for a failed in-place set build with GLOBAL IN #102308 (it is 3 weeks behind master on files that move a lot), or
  2. I carry a self-contained PR on master with just the two halves above, and drop the plumbing if Fix _path / _file filtering for object storage, file and url #112968 merges first?

I have the reproduction plan either way: slow IN subquery in a mutation predicate, then KILL MUTATION or DETACH, on a partitioned table so the minmax projection is eligible. Happy to do 2 on your word.

Family tracking issue is #107619.

alexey-milovidov and others added 3 commits August 5, 2026 08:41
…isible

`operator=(` also matched the `std::nullptr_t` overload, which merely
resets the object and has a short, informative name of its own, so a
frame in `f = nullptr;` was still displayed as `?`. Spell the copy and
move assignment as `operator=(std::function<` instead, and keep a
regression case for the `nullptr` reset path.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

The fix is in #114463.

Root cause is the mutation's interactive-cancel callback returning a bare bool. buildSetInplace
materializes the right side of IN (subquery) through a nested CompletedPipelineExecutor and polls
that callback, so on cancellation the executor called cancel() and the poll loop returned normally:
Set::finishInsert never ran, while build() had already moved the source plan out. Since
buildSetsForDAG returns void, getMinMaxCountProjectionBlock then evaluated the filter in the
same call and FunctionIn threw. The constant left-hand side in the fuzzed carrier (1 IN (...)) is
what makes this the first materialization attempt, which is why this sink is rare compared with
FilterTransform.

The callback now throws ABORTED, mirroring MergeTask::checkOperationIsNotCanceled, which already
reports the merge path this way from a nested-pipeline callback. Only the mutation installs this
callback shape, so the TCPHandler and LocalConnection installers are untouched and client
cancellation stays quiet.

One correction to my earlier comment on this thread: I said the fix needed both a buildSetInplace
rewrite and readiness guards at the two MergeTreeData sites. That was wrong. Once the cancellation
is reported, I could not construct any user-runnable input that reaches those guards, so shipping
them would have been dead code. #114463 is the callback change plus a test.

#109722 does not cover this sink, so I have not linked it as the fix.

amogiska pushed a commit to amogiska/ClickHouse that referenced this pull request Aug 12, 2026
…t-testability

A pure refactoring with no behavior change: the function was file-local in
`StackTrace.cpp`, compiled only under `#if (defined(__ELF__) && !defined(OS_FREEBSD)) || defined(OS_DARWIN)`;
now it is a public static member declared in `StackTrace.h` and defined
unconditionally.

This unblocks `Bugfix validation (unit tests)` for
ClickHouse#112152: the validation overlays
the PR's new regression test onto the merge-base and requires it to compile
there and fail at runtime, but the test calls
`StackTrace::collapseDemangledNames`, which did not exist on the merge-base, so
the "before" binary failed to compile and the validation was inconclusive:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112152&sha=c9b08639cb488c1a023376e2623d7b338748a89c&name_0=PR&name_1=Bugfix%20validation%20%28unit%20tests%29

Once this refactoring is in `master` and merged into that PR's branch, its
"before" binary compiles the test against the old behavior and the test fails
at runtime, turning the validation into a genuine reproduction.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 13, 2026
@alexey-milovidov alexey-milovidov self-assigned this Aug 13, 2026
Merged via the queue into master with commit 3662ba8 Aug 13, 2026
182 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-stacktrace-functional-name-suppression branch August 13, 2026 13:54
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 13, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 14, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 14, 2026
alexey-milovidov pushed a commit that referenced this pull request Aug 14, 2026
…t-testability

A pure refactoring with no behavior change: the function was file-local in
`StackTrace.cpp`, compiled only under `#if (defined(__ELF__) && !defined(OS_FREEBSD)) || defined(OS_DARWIN)`;
now it is a public static member declared in `StackTrace.h` and defined
unconditionally.

This unblocks `Bugfix validation (unit tests)` for
#112152: the validation overlays
the PR's new regression test onto the merge-base and requires it to compile
there and fail at runtime, but the test calls
`StackTrace::collapseDemangledNames`, which did not exist on the merge-base, so
the "before" binary failed to compile and the validation was inconclusive:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112152&sha=c9b08639cb488c1a023376e2623d7b338748a89c&name_0=PR&name_1=Bugfix%20validation%20%28unit%20tests%29

Once this refactoring is in `master` and merged into that PR's branch, its
"before" binary compiles the test against the old behavior and the test fails
at runtime, turning the validation into a genuine reproduction.

Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov pushed a commit that referenced this pull request Aug 14, 2026
…t-testability

A pure refactoring with no behavior change: the function was file-local in
`StackTrace.cpp`, compiled only under `#if (defined(__ELF__) && !defined(OS_FREEBSD)) || defined(OS_DARWIN)`;
now it is a public static member declared in `StackTrace.h` and defined
unconditionally.

This unblocks `Bugfix validation (unit tests)` for
#112152: the validation overlays
the PR's new regression test onto the merge-base and requires it to compile
there and fail at runtime, but the test calls
`StackTrace::collapseDemangledNames`, which did not exist on the merge-base, so
the "before" binary failed to compile and the validation was inconclusive:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112152&sha=c9b08639cb488c1a023376e2623d7b338748a89c&name_0=PR&name_1=Bugfix%20validation%20%28unit%20tests%29

Once this refactoring is in `master` and merged into that PR's branch, its
"before" binary compiles the test against the old behavior and the test fails
at runtime, turning the validation into a genuine reproduction.

Co-Authored-By: Claude Fable 5 <[email protected]>
clickhouse-gh Bot pushed a commit that referenced this pull request Aug 15, 2026
…ributed to a libc++ `__functional` header
clickhouse-gh Bot added a commit that referenced this pull request Aug 15, 2026
Backport #112152 to 26.7: Keep the function name of a stack frame attributed to a libc++ `__functional` header
alexey-milovidov added a commit that referenced this pull request Aug 15, 2026
Backport #112152 to 26.5: Keep the function name of a stack frame attributed to a libc++ `__functional` header
pull Bot pushed a commit to Haofei/ClickHouse that referenced this pull request Aug 17, 2026
…ently

A mutation whose predicate contains `IN (subquery)` materializes the right-hand
side through `FutureSetFromSubquery::buildSetInplace`, which runs a nested
`CompletedPipelineExecutor` and polls the mutation's interactive-cancel callback.
The callback returned a bare `bool`, so on cancellation the executor called
`cancel()` and the poll loop returned normally: `CreatingSetsTransform::generate`
and therefore `Set::finishInsert` never ran, leaving the set uncreated while
`build()` had already moved the source plan out. `buildSetsForDAG` returns void,
so `getMinMaxCountProjectionBlock` went on to evaluate the filter in the same
call and `FunctionIn` threw "Not-ready Set is passed as the second argument for
function 'in'" - a server abort in debug and sanitizer builds.

Reported by @ alexey-milovidov on
ClickHouse#112152 (comment)
after a Stress test (amd_debug) run aborted this way. `DETACH DATABASE` during a
running mutation is the trigger seen in CI; `KILL MUTATION` reproduces it.

The callback now throws `ABORTED` on cancellation, mirroring
`MergeTask::checkOperationIsNotCanceled`, which reports the merge path the same
way and is likewise wired into nested pipelines.
`MergeTreeBackgroundExecutor` already treats `ABORTED` as a normal outcome and
logs it at DEBUG. Only the mutation installs this callback shape; the two
interactive installers in `TCPHandler` and `LocalConnection` are untouched, so
client-side cancellation still returns `QUERY_WAS_CANCELLED` quietly.

Instrumented measurement of the cancel path before the fix: of three mutating
parts, one returned from `execute()` with no exception and an uncreated set,
while the other two observed the `UNKNOWN_EXCEPTION` that
`~CreatingSetsTransform` sets on the shared promise - so the loud report was a
race, not a contract.

A readiness guard at the projection site was measured and deliberately not
added: with the cancellation reported, no user-runnable input reaches that sink.

Related: ClickHouse#107619

Co-Authored-By: Claude Fable 5 <[email protected]>
@azat azat added the post-approved Approved, but after the PR is merged. label Aug 17, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Aug 18, 2026
…ributed to a libc++ `__functional` header
clickhouse-gh Bot added a commit that referenced this pull request Aug 18, 2026
Backport #112152 to 26.6: Keep the function name of a stack frame attributed to a libc++ `__functional` header
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
… frame attributed to a libc++ `__functional` header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

post-approved Approved, but after the PR is merged. 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-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.4-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants