From 67bedc970340175abcb6586eed639cdf0620bc8f Mon Sep 17 00:00:00 2001 From: stdpain <34912776+stdpain@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:07:33 +0800 Subject: [PATCH] [BugFix] Fix ASAN crash when push null chunk to accumulator (#19270) Signed-off-by: stdpain (cherry picked from commit 745e3186333a64fa3ba11603973b37b4393e93ce) Signed-off-by: stdpain <34912776+stdpain@users.noreply.github.com> --- .../sorted_aggregate_streaming_sink_operator.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/be/src/exec/pipeline/aggregate/sorted_aggregate_streaming_sink_operator.cpp b/be/src/exec/pipeline/aggregate/sorted_aggregate_streaming_sink_operator.cpp index bb2677a1f5e81..a33120f185f50 100644 --- a/be/src/exec/pipeline/aggregate/sorted_aggregate_streaming_sink_operator.cpp +++ b/be/src/exec/pipeline/aggregate/sorted_aggregate_streaming_sink_operator.cpp @@ -50,10 +50,15 @@ Status SortedAggregateStreamingSinkOperator::set_finishing(RuntimeState* state) _is_finished = true; ASSIGN_OR_RETURN(auto res, _aggregator->pull_eos_chunk()); DCHECK(_accumulator.need_input()); - _accumulator.push(std::move(res)); + if (res && !res->is_empty()) { + _accumulator.push(std::move(res)); + } _accumulator.finalize(); - auto accumulated = std::move(_accumulator.pull()); - _aggregator->offer_chunk_to_buffer(accumulated); + if (_accumulator.has_output()) { + auto accumulated = std::move(_accumulator.pull()); + _aggregator->offer_chunk_to_buffer(accumulated); + } + _aggregator->set_ht_eos(); _aggregator->sink_complete(); return Status::OK();