From 504693be7f890392035022739f0933b611a833e2 Mon Sep 17 00:00:00 2001 From: xy720 <22125576+xy720@users.noreply.github.com> Date: Wed, 20 Dec 2023 20:02:48 +0800 Subject: [PATCH] [bug](coredump) Fix coredump in aggregation node's destruction(#28684) fix coredump in aggregation node's destruction --- be/src/vec/exec/vaggregation_node.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/be/src/vec/exec/vaggregation_node.cpp b/be/src/vec/exec/vaggregation_node.cpp index c594e99d02df1d..69a50ba891b5bf 100644 --- a/be/src/vec/exec/vaggregation_node.cpp +++ b/be/src/vec/exec/vaggregation_node.cpp @@ -847,13 +847,20 @@ void AggregationNode::_emplace_into_hash_table(AggregateDataPtr* places, ColumnR agg_method.init_serialized_keys(key_columns, num_rows); auto creator = [this](const auto& ctor, auto& key, auto& origin) { - HashMethodType::try_presis_key(key, origin, *_agg_arena_pool); - auto mapped = _aggregate_data_container->append_data(origin); - auto st = _create_agg_status(mapped); - if (!st) { - throw Exception(st.code(), st.to_string()); + try { + HashMethodType::try_presis_key(key, origin, *_agg_arena_pool); + auto mapped = _aggregate_data_container->append_data(origin); + auto st = _create_agg_status(mapped); + if (!st) { + throw Exception(st.code(), st.to_string()); + } + ctor(key, mapped); + } catch (...) { + // Exception-safety - if it can not allocate memory or create status, + // the destructors will not be called. + ctor(key, nullptr); + throw; } - ctor(key, mapped); }; auto creator_for_null_key = [this](auto& mapped) {