apache/hadoop · warning
detachCurrentThreadFromJvm: Unable to detach thread %s from
Error message
detachCurrentThreadFromJvm: Unable to detach thread %s from the JVM. Error code: %d
What it means
Windows TLS destructor: DetachCurrentThread returned a value other than JNI_OK (e.g. JNI_EDETACHED, the thread was not attached). The thread id string is fetched via the JVM for context, then the state is freed. Teardown-time warning; no data is lost beyond the log line.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c:66
}
env = state->env;
if ((env == NULL) || (*env == NULL)) {
return;
}
ret = (*env)->GetJavaVM(env, &vm);
if (ret) {
fprintf(stderr,
"detachCurrentThreadFromJvm: GetJavaVM failed with error %d\n",
ret);
(*env)->ExceptionDescribe(env);
} else {
ret = (*vm)->DetachCurrentThread(vm);
if (ret != JNI_OK) {
(*env)->ExceptionDescribe(env);
get_current_thread_id(env, thr_name, MAXTHRID);
fprintf(stderr, "detachCurrentThreadFromJvm: Unable to detach thread %s "
"from the JVM. Error code: %d\n", thr_name, ret);
}
}
/* Free exception strings */
if (state->lastExceptionStackTrace) free(state->lastExceptionStackTrace);
if (state->lastExceptionRootCause) free(state->lastExceptionRootCause);
/* Free the state itself */
free(state);
}
static void get_current_thread_id(JNIEnv* env, char* id, int max) {
jclass cls;
jmethodID mth;
jobject thr;
jstring thr_name;
jlong thr_id = 0;View on GitHub (pinned to 2add963021)
Solutions
- Informational at shutdown — no action unless accompanied by failures
- If recurring mid-run, audit double-detach sources in-process
- Keep HDFS calls off threads during teardown
Defensive patterns
Strategy: fallback
Prevention
- Prevent other JNI libraries from detaching libhdfs threads
- Shut down HDFS activity before beginning teardown
- Classify shutdown-only occurrences as log noise
When it happens
Trigger: Double-detach at DLL detach time; detach attempted while the JVM is being destroyed and refuses.
Common situations: Other native libraries managing attachment; exit-order races between DLL unload and JVM destruction.
Related errors
- detachCurrentThreadFromJvm: GetJavaVM failed with error %d
- hdfsThreadDestructor: Unable to detach thread %s from the JV
- PrintExceptionAndFree: error determining class name of excep
- error:
- (unable to get root cause for %s)
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/05fbbeff2826b984.
Report an issue: GitHub.