I believe I found a bug in getLibraryHandle.

This was encountered when writing an osgEarth application, using the
osgEarthQt widgets (Qt 4.8.6).

A segfault was encountered shortly after starting the application, when
pressing 's' (To bring up the standard set of rendering stats).

I traced this to the dlopen( localLibraryName.c_str(), RTLD_LAZY |
RTLD_GLOBAL) call in osg/src/osgDB/DynamicLibrary.cpp

According to the dlopen manpage:

As at glibc 2.21, specifying the *RTLD_GLOBAL *flag when calling
       *dlmopen*() generates an error.  Furthermore, specifying *RTLD_GLOBAL*
       when calling *dlopen*() results in a program crash (*SIGSEGV*) if the
       call is made from any object loaded in a namespace other than the
       initial namespace.


Changing osg to use RTLD_LOCAL avoids the crash, and doesn't seem to break
anything else as far as I can tell.

Is there a specific reason why RTLD_GLOBAL is used? This doesn't make much
sense given the plugin architecture..


I've attached a minimal patch including the fix.


Thanks
Gareth Francis
--- DynamicLibrary.cpp	2015-09-21 11:06:56.281297930 +0100
+++ DynamicLibrary.cpp.modified	2015-09-21 11:06:47.420349338 +0100
@@ -119,7 +119,7 @@
         localLibraryName = "./" + libraryName;
     else
         localLibraryName = libraryName;
-    handle = dlopen( localLibraryName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
+    handle = dlopen( localLibraryName.c_str(), RTLD_LAZY | RTLD_LOCAL);
     if( handle == NULL )
     {
         if (fileExists(localLibraryName))
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to