From 6c0c66e66420cb2433fb63ca7c139ce4e4c960d2 Mon Sep 17 00:00:00 2001 From: yiguolei <676222867@qq.com> Date: Wed, 26 Jul 2023 14:46:24 +0800 Subject: [PATCH] [exceptionsafe](expr) exprcontext's open and prepare method should catch exception (#22230) Co-authored-by: yiguolei ExprContext may throw exception during expr->open, and it will core in non-pipeline mode. --- be/src/vec/exprs/vexpr_context.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/be/src/vec/exprs/vexpr_context.cpp b/be/src/vec/exprs/vexpr_context.cpp index 70ae91b060..1592618456 100644 --- a/be/src/vec/exprs/vexpr_context.cpp +++ b/be/src/vec/exprs/vexpr_context.cpp @@ -67,7 +67,9 @@ doris::Status VExprContext::execute(doris::vectorized::Block* block, int* result doris::Status VExprContext::prepare(doris::RuntimeState* state, const doris::RowDescriptor& row_desc) { _prepared = true; - return _root->prepare(state, row_desc, this); + Status st; + RETURN_IF_CATCH_EXCEPTION({ st = _root->prepare(state, row_desc, this); }); + return st; } doris::Status VExprContext::open(doris::RuntimeState* state) { @@ -80,7 +82,9 @@ doris::Status VExprContext::open(doris::RuntimeState* state) { // original's fragment state and only need to have thread-local state initialized. FunctionContext::FunctionStateScope scope = _is_clone ? FunctionContext::THREAD_LOCAL : FunctionContext::FRAGMENT_LOCAL; - return _root->open(state, this, scope); + Status st; + RETURN_IF_CATCH_EXCEPTION({ st = _root->open(state, this, scope); }); + return st; } void VExprContext::close() {