src/hotspot/os/linux/os_linux.cpp
changeset 55291 47ee6c00d27c
parent 55238 3bd979f09721
child 55325 24c59b1579d7
--- a/src/hotspot/os/linux/os_linux.cpp	Fri Jun 07 08:47:28 2019 -0300
+++ b/src/hotspot/os/linux/os_linux.cpp	Wed Jun 05 16:53:52 2019 +0200
@@ -1881,8 +1881,17 @@
                                 int ebuflen) {
   void * result = ::dlopen(filename, RTLD_LAZY);
   if (result == NULL) {
-    ::strncpy(ebuf, ::dlerror(), ebuflen - 1);
-    ebuf[ebuflen-1] = '\0';
+    const char* error_report = ::dlerror();
+    if (error_report == NULL) {
+      error_report = "dlerror returned no error description";
+    }
+    if (ebuf != NULL && ebuflen > 0) {
+      ::strncpy(ebuf, error_report, ebuflen-1);
+      ebuf[ebuflen-1]='\0';
+    }
+    Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
+  } else {
+    Events::log(NULL, "Loaded shared library %s", filename);
   }
   return result;
 }