{"record":{"id":"b0af2414dc7fba21","repo":"apache/hadoop","slug":"error-no-exception","errorCode":null,"errorMessage":" error: (no exception)","messagePattern":" error: \\(no exception\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c","lineNumber":230,"sourceCode":"    va_start(ap, fmt);\n    ret = printExceptionAndFreeV(env, exc, noPrintFlags, fmt, ap);\n    va_end(ap);\n    return ret;\n}\n\nint printPendingExceptionAndFree(JNIEnv *env, int noPrintFlags,\n        const char *fmt, ...)\n{\n    va_list ap;\n    int ret;\n    jthrowable exc;\n\n    exc = (*env)->ExceptionOccurred(env);\n    if (!exc) {\n        va_start(ap, fmt);\n        vfprintf(stderr, fmt, ap);\n        va_end(ap);\n        fprintf(stderr, \" error: (no exception)\");\n        ret = 0;\n    } else {\n        (*env)->ExceptionClear(env);\n        va_start(ap, fmt);\n        ret = printExceptionAndFreeV(env, exc, noPrintFlags, fmt, ap);\n        va_end(ap);\n    }\n    return ret;\n}\n\njthrowable getPendingExceptionAndClear(JNIEnv *env)\n{\n    jthrowable jthr = (*env)->ExceptionOccurred(env);\n    if (!jthr)\n        return NULL;\n    (*env)->ExceptionClear(env);\n    return jthr;\n}","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c#L212-L248","documentation":"printPendingExceptionAndFree first calls ExceptionOccurred(); if no Java exception is actually pending it prints this fragment and returns 0. It signals that a libhdfs error path was entered without a thrown exception - typically a JNI function returned NULL/error without raising one, which is classic JVM resource-exhaustion behavior - so there is nothing to describe or map to an errno.","triggerScenarios":"Example: the hdfsOpenFile NewGlobalRef failure path - NewGlobalRef returns NULL without throwing, printPendingExceptionAndFree is called, ExceptionOccurred() is NULL, so this prints and ret stays 0 while the operation still failed (NULL handle).","commonSituations":"JVM heap/native exhaustion inside long-running libhdfs clients; error-handling paths invoked after an exception was already cleared elsewhere; rarely, JNI bugs across JVM versions.","solutions":["Treat this as a JVM-level failure: check LIBHDFS_OPTS -Xmx and the process's memory footprint (RSS vs cgroup/rlimit).","Audit the code path: if a JNI call can fail without throwing, set a meaningful errno before the print helper is called instead of relying on it.","Reproduce with `hdfs dfs` under the same CLASSPATH to see whether the Java side fails identically.","Upgrade to a matched libhdfs + Hadoop jar set if the pattern persists across releases."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate JNI-level results instead of trusting errno after libhdfs calls\nhdfsFile f = hdfsOpenFile(fs, path, O_WRONLY | O_CREAT, 0, 0, 0);\nif (!f && errno == 0) {\n    /* '(no exception)' path: JNI failed without a Java exception - JVM-level trouble */\n    treat_as_jvm_resource_failure();\n}","typeGuard":null,"tryCatchPattern":"hdfsFile f = hdfsOpenFile(fs, path, O_WRONLY, 0, 0, 0);\nif (!f) {\n    if (errno == 0 || errno == EINTERNAL) {\n        /* no pending exception was found: JVM-side failure, check heap/JVM state */\n    } else {\n        /* normal mapped-exception path */\n    }\n}","preventionTips":["Never assume errno is set when a libhdfs handle comes back NULL - check it explicitly.","Monitor and cap JVM memory (LIBHDFS_OPTS -Xmx) in processes embedding libhdfs; JNI calls failing without exceptions are a classic exhaustion signature.","Keep libhdfs and Hadoop jars version-matched.","In wrappers around libhdfs, set a synthetic errno (e.g. EIO) when errno==0 after a failed call."],"tags":["c","libhdfs","jni","jvm","oom","error-handling"],"backgroundTag":"jni-no-pending-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}