Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix the mem leak of VectorizedFunctionCallExpr #44275

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions be/src/exprs/function_call_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ Status VectorizedFunctionCallExpr::open(starrocks::RuntimeState* state, starrock

void VectorizedFunctionCallExpr::close(starrocks::RuntimeState* state, starrocks::ExprContext* context,
FunctionContext::FunctionStateScope scope) {
// _fn_context_index > 0 means this function call has call opened
if (_fn_desc != nullptr && _fn_desc->close_function != nullptr && _fn_context_index > 0) {
// _fn_context_index >= 0 means this function call has call opened
if (_fn_desc != nullptr && _fn_desc->close_function != nullptr && _fn_context_index >= 0) {
FunctionContext* fn_ctx = context->fn_context(_fn_context_index);
(void)_fn_desc->close_function(fn_ctx, FunctionContext::THREAD_LOCAL);

Expand Down
27 changes: 27 additions & 0 deletions be/test/exprs/function_call_expr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,31 @@ TEST_F(VectorizedFunctionCallExprTest, prepareFaileCase) {
exprContext.close(nullptr);
}

TEST_F(VectorizedFunctionCallExprTest, prepare_close) {
TFunction func;
func.__set_fid(60010); // like
func.__set_binary_type(TFunctionBinaryType::BUILTIN);

TExprNode expr_node;
expr_node.__set_fn(func);
expr_node.__set_opcode(TExprOpcode::ADD);
expr_node.__set_child_type(TPrimitiveType::INT);
expr_node.__set_node_type(TExprNodeType::BINARY_PRED);
expr_node.__set_num_children(2);
expr_node.__set_type(gen_type_desc(TPrimitiveType::BOOLEAN));

VectorizedFunctionCallExpr expr(expr_node);
ColumnRef col1(TypeDescriptor::create_varbinary_type(10), 1);
ColumnRef col2(TypeDescriptor::create_varbinary_type(10), 2);
expr.add_child(&col1);
expr.add_child(&col2);

ExprContext expr_context(&expr);
Status st = expr_context.prepare(&_runtime_state);
ASSERT_TRUE(st.ok());
st = expr_context.open(&_runtime_state);
ASSERT_TRUE(st.ok());
expr_context.close(&_runtime_state);
}

} // namespace starrocks
Loading