{"record":{"id":"05fbbeff2826b984","repo":"apache/hadoop","slug":"detachcurrentthreadfromjvm-unable-to-detach-threa","errorCode":null,"errorMessage":"detachCurrentThreadFromJvm: Unable to detach thread %s from the JVM. Error code: %d\n","messagePattern":"detachCurrentThreadFromJvm: Unable to detach thread (.+?) from the JVM\\. Error code: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c","lineNumber":66,"sourceCode":"  }\n  env = state->env;\n  if ((env == NULL) || (*env == NULL)) {\n    return;\n  }\n  ret = (*env)->GetJavaVM(env, &vm);\n  if (ret) {\n    fprintf(stderr,\n      \"detachCurrentThreadFromJvm: GetJavaVM failed with error %d\\n\",\n      ret);\n    (*env)->ExceptionDescribe(env);\n  } else {\n    ret = (*vm)->DetachCurrentThread(vm);\n\n    if (ret != JNI_OK) {\n      (*env)->ExceptionDescribe(env);\n      get_current_thread_id(env, thr_name, MAXTHRID);\n\n      fprintf(stderr, \"detachCurrentThreadFromJvm: Unable to detach thread %s \"\n          \"from the JVM. Error code: %d\\n\", thr_name, ret);\n    }\n  }\n\n  /* Free exception strings */\n  if (state->lastExceptionStackTrace) free(state->lastExceptionStackTrace);\n  if (state->lastExceptionRootCause) free(state->lastExceptionRootCause);\n\n  /* Free the state itself */\n  free(state);\n}\n\nstatic void get_current_thread_id(JNIEnv* env, char* id, int max) {\n  jclass cls;\n  jmethodID mth;\n  jobject thr;\n  jstring thr_name;\n  jlong thr_id = 0;","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/os/windows/thread_local_storage.c#L48-L84","documentation":"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.","triggerScenarios":"Double-detach at DLL detach time; detach attempted while the JVM is being destroyed and refuses.","commonSituations":"Other native libraries managing attachment; exit-order races between DLL unload and JVM destruction.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prevent other JNI libraries from detaching libhdfs threads","Shut down HDFS activity before beginning teardown","Classify shutdown-only occurrences as log noise"],"tags":["libhdfs","windows","jni","detachcurrentthread","dll"],"backgroundTag":"jni-thread-detach-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}