From 8d21f207537e170da8a83a435e83c6b01d06faba Mon Sep 17 00:00:00 2001 From: yiguolei <676222867@qq.com> Date: Tue, 25 Apr 2023 15:26:54 +0800 Subject: [PATCH] [enhancement](javaudf) not depend on parent will cause deconstructor core (#18948) Co-authored-by: yiguolei --- be/src/vec/functions/function_java_udf.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/be/src/vec/functions/function_java_udf.h b/be/src/vec/functions/function_java_udf.h index b04097c24d..b1cae9289e 100644 --- a/be/src/vec/functions/function_java_udf.h +++ b/be/src/vec/functions/function_java_udf.h @@ -96,8 +96,11 @@ private: }; struct JniContext { - JavaFunctionCall* parent = nullptr; - + // Do not save parent directly, because parent is in VExpr, but jni context is in FunctionContext + // The deconstruct sequence is not determined, it will core. + // JniContext's lifecycle should same with function context, not related with expr + jclass executor_cl_; + jmethodID executor_close_id_; jobject executor = nullptr; bool is_closed = false; @@ -120,7 +123,8 @@ private: std::unique_ptr output_intermediate_state_ptr; JniContext(int64_t num_args, JavaFunctionCall* parent) - : parent(parent), + : executor_cl_(parent->executor_cl_), + executor_close_id_(parent->executor_close_id_), input_values_buffer_ptr(new int64_t[num_args]), input_nulls_buffer_ptr(new int64_t[num_args]), input_offsets_ptrs(new int64_t[num_args]), @@ -145,8 +149,7 @@ private: LOG(WARNING) << "errors while get jni env " << status; return; } - env->CallNonvirtualVoidMethodA(executor, parent->executor_cl_, - parent->executor_close_id_, NULL); + env->CallNonvirtualVoidMethodA(executor, executor_cl_, executor_close_id_, NULL); Status s = JniUtil::GetJniExceptionMsg(env); if (!s.ok()) LOG(WARNING) << s; env->DeleteGlobalRef(executor);