Skip to content

Commit

Permalink
[fix](jni) avoid coredump if failed to get jni env (apache#32950)
Browse files Browse the repository at this point in the history
This PR apache#32217 find a problem that may failed to get jni env.
And it did a work around to avoid BE crash.

This PR followup this issue, to avoid BE crash when doing `close()` of JniConnector
if failed to get jni env.

The `close()` method will return error when:
1. Failed to get jni env
2. Failed to release jni resource.

This PR will ignore the first error, and still log fatal for second error
  • Loading branch information
morningman committed Apr 7, 2024
1 parent c758a25 commit ed93d61
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions be/src/vec/exec/jni_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ namespace doris::vectorized {
M(TypeIndex::DateTimeV2, ColumnVector<UInt64>, UInt64)

JniConnector::~JniConnector() {
Status st = close();
if (!st.ok()) {
// Ensure successful resource release
LOG(FATAL) << "Failed to release jni resource: " << st.to_string();
}
static_cast<void>(close());
}

Status JniConnector::open(RuntimeState* state, RuntimeProfile* profile) {
Expand Down Expand Up @@ -182,8 +178,9 @@ Status JniConnector::close() {
_closed = true;
jthrowable exc = (env)->ExceptionOccurred();
if (exc != nullptr) {
LOG(WARNING) << "Failed to release jni resource: "
<< JniUtil::GetJniExceptionMsg(env).to_string();
// Ensure successful resource release
LOG(FATAL) << "Failed to release jni resource: "
<< JniUtil::GetJniExceptionMsg(env).to_string();
}
}
return Status::OK();
Expand Down

0 comments on commit ed93d61

Please sign in to comment.