{"record":{"id":"ea7889291fe6c958","repo":"apache/hadoop","slug":"unable-to-get-stack-trace-for-s","errorCode":null,"errorMessage":"(unable to get stack trace for %s)\n","messagePattern":"\\(unable to get stack trace for (.+?)\\)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c","lineNumber":195,"sourceCode":"\n    // We don't want to use ExceptionDescribe here, because that requires a\n    // pending exception. Instead, use ExceptionUtils.\n    rootCause = getExceptionUtilString(env, exc, \"getRootCauseMessage\");\n    stackTrace = getExceptionUtilString(env, exc, \"getStackTrace\");\n    // Save the exception details in the thread-local state.\n    setTLSExceptionStrings(rootCause, stackTrace);\n\n    if (!noPrint) {\n        vfprintf(stderr, fmt, ap);\n        fprintf(stderr, \" error:\\n\");\n\n        if (!rootCause) {\n            fprintf(stderr, \"(unable to get root cause for %s)\\n\", className);\n        } else {\n            fprintf(stderr, \"%s\", rootCause);\n        }\n        if (!stackTrace) {\n            fprintf(stderr, \"(unable to get stack trace for %s)\\n\", className);\n        } else {\n            fprintf(stderr, \"%s\", stackTrace);\n        }\n    }\n\n    destroyLocalReference(env, exc);\n    free(className);\n    return excErrno;\n}\n\nint printExceptionAndFree(JNIEnv *env, jthrowable exc, int noPrintFlags,\n        const char *fmt, ...)\n{\n    va_list ap;\n    int ret;\n\n    va_start(ap, fmt);\n    ret = printExceptionAndFreeV(env, exc, noPrintFlags, fmt, ap);","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c#L177-L213","documentation":"printExceptionAndFreeV calls org.apache.hadoop.util.ExceptionUtils.getStackTrace over JNI to render the Java stack trace of a failed libhdfs operation; when getExceptionUtilString returns NULL (invokeMethod threw or the C-string copy failed), this placeholder with the exception class name is printed instead. The errno mapping and root-cause extraction are independent, so they may still succeed.","triggerScenarios":"A libhdfs operation threw a Java exception AND the ExceptionUtils.getStackTrace call failed: hadoop-common on CLASSPATH too old to have that method (pre-3.x jar), JVM OOM while formatting, or newCStr allocation failure.","commonSituations":"Mixed-version hadoop jars on CLASSPATH; memory-pressured JVMs where diagnostic calls fail after the main operation already threw; stripped-down hadoop-common bundles.","solutions":["Verify a single consistent Hadoop version on CLASSPATH (hdfs classpath --glob from the matching install).","Use hdfsGetLastExceptionRootCause() - the root cause is fetched by a separate call and may still be available.","Reproduce the failing operation with `hdfs dfs` using the same CLASSPATH to capture the stack trace from the Java side.","Raise LIBHDFS_OPTS -Xmx if both root-cause and stack-trace diagnostics fail (points at JVM OOM)."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"const char *st = hdfsGetLastExceptionStackTrace();\nif (!st) {\n    /* stack trace unavailable: fall back to root cause + mapped errno */\n    const char *rc = hdfsGetLastExceptionRootCause();\n    handle_failure(errno, rc ? rc : \"no diagnostics available\");\n} else {\n    handle_failure(errno, st);\n}","preventionTips":["Keep hadoop-common and libhdfs versions identical so ExceptionUtils.getStackTrace resolves.","Reproduce failures with `hdfs dfs` under the same CLASSPATH to capture the Java-side trace when native diagnostics fail.","Treat 'both root cause and stack trace NULL' as a JVM-memory red flag.","Always handle NULL from hdfsGetLastExceptionStackTrace()."],"tags":["c","libhdfs","jni","classpath","version-mismatch","diagnostics"],"backgroundTag":"jni-exception-diagnostics-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}