This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch branch-3.4.2
in repository https://gitbox.apache.org/repos/asf/impala.git

commit d1f0595efea9ea53e24cda2d66ba695bfefa879b
Author: ttttttz <[email protected]>
AuthorDate: Thu Apr 27 10:37:47 2023 +0800

    IMPALA-12102: Avoid memory leaks in the handling of JNI exceptions
    
    During the processing of JNI Exceptions, some local references
    were not released in a timely manner, which may lead to memory
    leaks in the JVM.
    
    Testing:
    - Manually verified that the memory leak doesn't occur in the
      local development environment.
    
    Change-Id: I4843df07dd0f9d3dc237f91db4ec00721ebbd680
    Reviewed-on: http://gerrit.cloudera.org:8080/19810
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 be/src/util/jni-util.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/be/src/util/jni-util.cc b/be/src/util/jni-util.cc
index 62df916be..3205c5b22 100644
--- a/be/src/util/jni-util.cc
+++ b/be/src/util/jni-util.cc
@@ -286,10 +286,13 @@ Status JniUtil::GetJniExceptionMsg(JNIEnv* env, bool 
log_stack, const string& pr
     JniUtfCharGuard c_stack_guard;
     RETURN_IF_ERROR(JniUtfCharGuard::create(env, stack, &c_stack_guard));
     VLOG(1) << c_stack_guard.get();
+    env->DeleteLocalRef(stack);
   }
 
+  const char* msg_str = msg_str_guard.get();
+  env->DeleteLocalRef(msg);
   env->DeleteLocalRef(exc);
-  return Status(Substitute("$0$1", prefix, msg_str_guard.get()));
+  return Status(Substitute("$0$1", prefix, msg_str));
 }
 
 Status JniUtil::GetJvmMemoryMetrics(TGetJvmMemoryMetricsResponse* result) {

Reply via email to