diff Core/SharedLibrary.cpp @ 3786:3801435e34a1 SylvainRouquette/fix-issue169-95b752c

integration Orthanc-1.6.0->SylvainRouquette
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 19 Mar 2020 11:48:30 +0100
parents b7087f928050
children 626d5f4a5afb
line wrap: on
line diff
--- a/Core/SharedLibrary.cpp	Wed Mar 18 08:59:06 2020 +0100
+++ b/Core/SharedLibrary.cpp	Thu Mar 19 11:48:30 2020 +0100
@@ -2,7 +2,7 @@
  * Orthanc - A Lightweight, RESTful DICOM Store
  * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
  * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2019 Osimis S.A., Belgium
+ * Copyright (C) 2017-2020 Osimis S.A., Belgium
  *
  * This program is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -62,7 +62,19 @@
     }
 
 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-    handle_ = ::dlopen(path_.c_str(), RTLD_NOW);
+
+    /**
+     * "RTLD_LOCAL" is the default, and is only present to be
+     * explicit. "RTLD_DEEPBIND" was added in Orthanc 1.6.0, in order
+     * to avoid crashes while loading plugins from the LSB binaries of
+     * the Orthanc core.
+     **/
+#if defined(RTLD_DEEPBIND)  // This is a GNU extension
+    handle_ = ::dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
+#else
+    handle_ = ::dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL);
+#endif
+
     if (handle_ == NULL) 
     {
       std::string explanation;