diff --git a/cpp/velox/udf/UdfLoader.cc b/cpp/velox/udf/UdfLoader.cc index 857fae0c3f67..430927b2bf0a 100644 --- a/cpp/velox/udf/UdfLoader.cc +++ b/cpp/velox/udf/UdfLoader.cc @@ -36,9 +36,13 @@ void* loadSymFromLibrary( const std::string& libPath, const std::string& func, bool throwIfNotFound = true) { + // Clear any existing dlerror() state before calling dlsym. + dlerror(); void* sym = dlsym(handle, func.c_str()); if (!sym && throwIfNotFound) { - throw gluten::GlutenException(func + " not found in " + libPath); + const char* error = dlerror(); + throw gluten::GlutenException( + fmt::format("Failed to load {} in {}: {}", func, libPath, error != nullptr ? error : "unknown error")); } return sym; }