This is an automated email from the ASF dual-hosted git repository.

marin-ma pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 29e986d896 [VL] Report the real error when a UDF library fails to load 
(#13513)
29e986d896 is described below

commit 29e986d896088ba751f7238319877f99f9d5ed74
Author: Pedrum Jalali <[email protected]>
AuthorDate: Wed Nov 4 11:52:11 2026 -0800

    [VL] Report the real error when a UDF library fails to load (#13513)
---
 cpp/velox/tests/MyUdfTest.cc | 16 ++++++++++++++++
 cpp/velox/udf/UdfLoader.cc   |  5 +++++
 2 files changed, 21 insertions(+)

diff --git a/cpp/velox/tests/MyUdfTest.cc b/cpp/velox/tests/MyUdfTest.cc
index cee54bb013..7237655505 100644
--- a/cpp/velox/tests/MyUdfTest.cc
+++ b/cpp/velox/tests/MyUdfTest.cc
@@ -15,8 +15,11 @@
  * limitations under the License.
  */
 
+#include <filesystem>
+#include <fstream>
 #include <vector>
 #include "udf/UdfLoader.h"
+#include "utils/Exception.h"
 #include "velox/expression/SimpleFunctionRegistry.h"
 #include "velox/functions/prestosql/tests/utils/FunctionBaseTest.h"
 #include "velox/parse/TypeResolver.h"
@@ -40,3 +43,16 @@ TEST_F(MyUdfTest, hivestringstring) {
   const core::QueryConfig config({});
   EXPECT_EQ(TypeKind::VARCHAR, exec::simpleFunctions().resolveFunction(name, 
{VARCHAR(), VARCHAR()})->type()->kind());
 }
+
+TEST_F(MyUdfTest, invalidLibraryFailsToLoad) {
+  const auto path = std::filesystem::temp_directory_path() / 
"gluten_my_udf_test_invalid.so";
+  std::ofstream(path) << "not a shared library";
+  std::string error;
+  try {
+    gluten::UdfLoader::getInstance()->loadUdfLibraries(path.string());
+  } catch (const gluten::GlutenException& e) {
+    error = e.what();
+  }
+  std::filesystem::remove(path);
+  EXPECT_NE(error.find("Failed to load udf library " + path.string()), 
std::string::npos) << error;
+}
diff --git a/cpp/velox/udf/UdfLoader.cc b/cpp/velox/udf/UdfLoader.cc
index 430927b2bf..7f967d1934 100644
--- a/cpp/velox/udf/UdfLoader.cc
+++ b/cpp/velox/udf/UdfLoader.cc
@@ -60,6 +60,11 @@ void UdfLoader::loadUdfLibrariesInternal(const 
std::vector<std::string>& libPath
   for (const auto& libPath : libPaths) {
     if (handles_.find(libPath) == handles_.end()) {
       void* handle = dlopen(libPath.c_str(), RTLD_LAZY);
+      if (handle == nullptr) {
+        const char* error = dlerror();
+        throw gluten::GlutenException(
+            fmt::format("Failed to load udf library {}: {}", libPath, error != 
nullptr ? error : "unknown error"));
+      }
       handles_[libPath] = handle;
     }
     LOG(INFO) << "Successfully loaded udf library: " << libPath;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to