hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weic...@apache.org
Subject [hadoop] branch branch-3.1 updated: HDFS-15270. Account for *env == NULL in hdfsThreadDestructor (#1951)
Date Mon, 11 May 2020 17:47:05 GMT
This is an automated email from the ASF dual-hosted git repository.

weichiu pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 42997d1  HDFS-15270. Account for *env == NULL in hdfsThreadDestructor (#1951)
42997d1 is described below

commit 42997d14a9aa849778f4b02647f27d1a84ca01fb
Author: Babneet Singh <babsingh@users.noreply.github.com>
AuthorDate: Mon May 4 16:08:53 2020 -0400

    HDFS-15270. Account for *env == NULL in hdfsThreadDestructor (#1951)
    
    OpenJ9 JVM properly terminates the thread before hdfsThreadDestructor is
    invoked. JNIEnv is a mirror of J9VMThread in OpenJ9. After proper thread
    termination, accessing JNIEnv in hdfsThreadDestructor (*env)->GetJavaVM,
    yields a SIGSEGV since *env is NULL after thread cleanup is performed.
    
    The main purpose of hdfsThreadDestructor is to invoke
    DetachCurrentThread, which performs thread cleanup in OpenJ9. Since
    OpenJ9 performs thread cleanup before hdfsThreadDestructor is invoked,
    hdfsThreadDestructor should account for *env == NULL and skip
    DetachCurrentThread.
    
    Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
    (cherry picked from commit 1996351b0b7be6866eda73223ab6ef1ec78d30cd)
    (cherry picked from commit d1e5e393c30ef25212be365651404c1034532338)
    (cherry picked from commit 44fdee351dfaecb4012fc47761054cf84d67a667)
---
 .../src/main/native/libhdfs/os/posix/thread_local_storage.c           | 2 +-
 .../src/main/native/libhdfs/os/windows/thread_local_storage.c         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c
index e6b59d6..110c71a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/posix/thread_local_storage.c
@@ -43,7 +43,7 @@ void hdfsThreadDestructor(void *v)
   jint ret;
 
   /* Detach the current thread from the JVM */
-  if (env) {
+  if ((env != NULL) && (*env != NULL)) {
     ret = (*env)->GetJavaVM(env, &vm);
     if (ret) {
       fprintf(stderr, "hdfsThreadDestructor: GetJavaVM failed with error %d\n",
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c
index 28d014d..a8bd10d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c
@@ -39,10 +39,10 @@ static void detachCurrentThreadFromJvm()
   if (threadLocalStorageGet(&state) || !state) {
     return;
   }
-  if (!state->env) {
+  env = state->env;
+  if ((env == NULL) || (*env == NULL)) {
     return;
   }
-  env = state->env;
   ret = (*env)->GetJavaVM(env, &vm);
   if (ret) {
     fprintf(stderr,


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message