HDFS-12494. libhdfs SIGSEGV in setTLSExceptionStrings. Contributed by John Zhuge.

This commit is contained in:
John Zhuge 2017-10-04 22:55:01 -07:00 committed by John Zhuge
parent 5d63a388d1
commit 2856eb207b
1 changed files with 7 additions and 5 deletions

View File

@ -522,19 +522,21 @@ JNIEnv* getJNIEnv(void)
/* Create a ThreadLocalState for this thread */
state = threadLocalStorageCreate();
if (!state) {
mutexUnlock(&jvmMutex);
fprintf(stderr, "getJNIEnv: Unable to create ThreadLocalState\n");
return NULL;
}
if (threadLocalStorageSet(state)) {
mutexUnlock(&jvmMutex);
goto fail;
}
THREAD_LOCAL_STORAGE_SET_QUICK(state);
state->env = getGlobalJNIEnv();
mutexUnlock(&jvmMutex);
if (!state->env) {
goto fail;
}
if (threadLocalStorageSet(state)) {
goto fail;
}
THREAD_LOCAL_STORAGE_SET_QUICK(state);
return state->env;
fail: