[osg-users] osgDB::DynamicLibrary::getLibraryHandle - Crash due to calling dlopen with RTLD_GLOBAL
Gareth Francis
gfrancis.dev at gmail.com
Mon Sep 21 03:15:21 PDT 2015
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150921/67cece67/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RTLD_GLOBAL.patch
Type: text/x-patch
Size: 468 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150921/67cece67/attachment-0002.bin>
More information about the osg-users
mailing list