You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/06/01 15:29:15 UTC
[incubator-doris] 20/22: [Bug][Vectorized] fix core dump on vcase_expr::close (#9893)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit c1abaec0d5538910559fa7b0671c2f9b51217eb4
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Wed Jun 1 08:05:09 2022 +0800
[Bug][Vectorized] fix core dump on vcase_expr::close (#9893)
Co-authored-by: lihaopeng <li...@baidu.com>
---
be/src/vec/exec/volap_scanner.cpp | 3 ---
be/src/vec/exprs/vcase_expr.cpp | 16 ++++++++++++----
be/src/vec/exprs/vexpr.h | 5 +----
be/src/vec/functions/function_case.h | 11 +----------
be/src/vec/utils/util.hpp | 13 +++++++++++--
5 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/be/src/vec/exec/volap_scanner.cpp b/be/src/vec/exec/volap_scanner.cpp
index 4c86830b30..635b0f4a60 100644
--- a/be/src/vec/exec/volap_scanner.cpp
+++ b/be/src/vec/exec/volap_scanner.cpp
@@ -20,10 +20,7 @@
#include <memory>
#include "runtime/runtime_state.h"
-#include "vec/columns/column_complex.h"
-#include "vec/columns/column_nullable.h"
#include "vec/columns/column_string.h"
-#include "vec/columns/column_vector.h"
#include "vec/common/assert_cast.h"
#include "vec/core/block.h"
#include "vec/exec/volap_scan_node.h"
diff --git a/be/src/vec/exprs/vcase_expr.cpp b/be/src/vec/exprs/vcase_expr.cpp
index 20ad1fe340..2683e33bba 100644
--- a/be/src/vec/exprs/vcase_expr.cpp
+++ b/be/src/vec/exprs/vcase_expr.cpp
@@ -68,15 +68,23 @@ Status VCaseExpr::open(RuntimeState* state, VExprContext* context,
FunctionContext::FunctionStateScope scope) {
RETURN_IF_ERROR(VExpr::open(state, context, scope));
RETURN_IF_ERROR(VExpr::init_function_context(context, scope, _function));
-
- CaseState* case_state = new CaseState {_data_type};
- context->fn_context(_fn_context_index)->set_function_state(scope, case_state);
-
+ if (scope == doris_udf::FunctionContext::FRAGMENT_LOCAL) {
+ auto* case_state = new CaseState {_data_type};
+ context->fn_context(_fn_context_index)
+ ->set_function_state(FunctionContext::FRAGMENT_LOCAL, case_state);
+ }
return Status::OK();
}
void VCaseExpr::close(RuntimeState* state, VExprContext* context,
FunctionContext::FunctionStateScope scope) {
+ if (scope == doris_udf::FunctionContext::FRAGMENT_LOCAL) {
+ auto* case_state = reinterpret_cast<CaseState*>(
+ context->fn_context(_fn_context_index)
+ ->get_function_state(FunctionContext::FRAGMENT_LOCAL));
+ delete case_state;
+ }
+
VExpr::close_function_context(context, scope, _function);
VExpr::close(state, context, scope);
}
diff --git a/be/src/vec/exprs/vexpr.h b/be/src/vec/exprs/vexpr.h
index 31ccc8efba..7ebe597a0f 100644
--- a/be/src/vec/exprs/vexpr.h
+++ b/be/src/vec/exprs/vexpr.h
@@ -117,10 +117,7 @@ public:
VExpr* parent, int* node_idx, VExpr** root_expr,
VExprContext** ctx);
const std::vector<VExpr*>& children() const { return _children; }
- void set_children(RuntimeState* state, VExprContext* ctx, std::vector<VExpr*> children) {
- close(state, ctx, ctx->get_function_state_scope());
- _children = children;
- }
+ void set_children(std::vector<VExpr*> children) { _children = children; }
virtual std::string debug_string() const;
static std::string debug_string(const std::vector<VExpr*>& exprs);
static std::string debug_string(const std::vector<VExprContext*>& ctxs);
diff --git a/be/src/vec/functions/function_case.h b/be/src/vec/functions/function_case.h
index 5210ac80ad..47e33f58ff 100644
--- a/be/src/vec/functions/function_case.h
+++ b/be/src/vec/functions/function_case.h
@@ -327,21 +327,12 @@ public:
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
size_t result, size_t input_rows_count) override {
- CaseState* case_state = reinterpret_cast<CaseState*>(
+ auto* case_state = reinterpret_cast<CaseState*>(
context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
return execute_get_type(case_state->result_type, block, arguments, result,
input_rows_count);
}
-
- Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
- if (scope == FunctionContext::THREAD_LOCAL) {
- auto* state = reinterpret_cast<CaseState*>(
- context->get_function_state(FunctionContext::THREAD_LOCAL));
- delete state;
- }
- return Status::OK();
- }
};
} // namespace doris::vectorized
diff --git a/be/src/vec/utils/util.hpp b/be/src/vec/utils/util.hpp
index 8e50d12b5d..0df02ddd6a 100644
--- a/be/src/vec/utils/util.hpp
+++ b/be/src/vec/utils/util.hpp
@@ -69,7 +69,11 @@ public:
static constexpr auto is_leaf = [](VExpr* expr) { return !expr->is_and_expr(); };
if (is_leaf(expr)) {
- return checker(leaf_index++) ? nullptr : expr;
+ if (checker(leaf_index++)) {
+ expr->close(state, context, context->get_function_state_scope());
+ return nullptr;
+ }
+ return expr;
} else {
VExpr* left_child =
dfs_peel_conjunct(state, context, expr->children()[0], leaf_index, checker);
@@ -77,9 +81,14 @@ public:
dfs_peel_conjunct(state, context, expr->children()[1], leaf_index, checker);
if (left_child != nullptr && right_child != nullptr) {
- expr->set_children(state, context, {left_child, right_child});
+ expr->set_children({left_child, right_child});
return expr;
+ } else {
+ // here only close the and expr self, do not close the child
+ expr->set_children({});
+ expr->close(state, context, context->get_function_state_scope());
}
+
// here do not close Expr* now
return left_child != nullptr ? left_child : right_child;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org