Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
Impala 2.5.0, Impala 2.6.0, Impala 2.7.0, Impala 2.8.0
-
ghx-label-9
Description
Several places in the code do not handle JNI GetStringUTFChars() correctly.
1. GetStringUTFChars() returns NULL if there is insufficient memory
2. GetStringUTFChars() may set an exception in the JNI env. That exception must be checked and clearer before any other call to the JNI env.
Here's an example of the poor handling from jni-util.cc:
Status JniUtil::GetJniExceptionMsg(JNIEnv* env, bool log_stack, const string& prefix) { jthrowable exc = (env)->ExceptionOccurred(); if (exc == NULL) return Status::OK(); env->ExceptionClear(); DCHECK(throwable_to_string_id() != NULL); jstring msg = (jstring) env->CallStaticObjectMethod(jni_util_class(), throwable_to_string_id(), exc); jboolean is_copy; string error_msg = (reinterpret_cast<const char*>(env->GetStringUTFChars(msg, &is_copy))); if (log_stack) { jstring stack = (jstring) env->CallStaticObjectMethod(jni_util_class(), throwable_to_stack_trace_id(), exc); const char* c_stack = reinterpret_cast<const char*>(env->GetStringUTFChars(stack, &is_copy)); VLOG(1) << string(c_stack); } env->ExceptionClear(); env->DeleteLocalRef(exc); stringstream ss; ss << prefix << error_msg; return Status(ss.str()); }
Attachments
Attachments
Issue Links
- breaks
-
IMPALA-6060 Crash in JniUtfCharGuard::create()
-
- Resolved
-
- is duplicated by
-
IMPALA-5461 Crash in Frontend::ExecHiveServer2MetadataOp()
-
- Resolved
-