[osg-users] osgDB::DynamicLibrary::getLibraryHandle - Crash due to calling dlopen with RTLD_GLOBAL

Gareth Francis gfrancis.dev at gmail.com
Mon Sep 21 03:38:34 PDT 2015


CentOS 6.5
OSG 3.4.0
osgEarth 2.7


You might be right, I've just got the same crash using RTLD_LOCAL..
I've been having several problems relating to osgQt/X11 threading, so it's
possible that this is another symptom of that.

I can't reproduce this under a debugger, however I have been able to get a
core dump/backtrace:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000371e479bb7 in _int_malloc () from /lib64/libc.so.6
(gdb) bt
#0  0x000000371e479bb7 in _int_malloc () from /lib64/libc.so.6
#1  0x000000371e47b7da in _int_realloc () from /lib64/libc.so.6
#2  0x000000371e47baf5 in realloc () from /lib64/libc.so.6
#3  0x0000003c9e4a92ab in ?? () from /usr/lib64/libGL.so.1
#4  0x0000003c9e4aabd1 in ?? () from /usr/lib64/libGL.so.1
#5  0x0000003c9e4b148d in ?? () from /usr/lib64/libGL.so.1
#6  0x0000003c9e4aa345 in ?? () from /usr/lib64/libGL.so.1
#7  0x000000371e012bc3 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#8  0x000000371e00e266 in _dl_catch_error () from
/lib64/ld-linux-x86-64.so.2
#9  0x000000371e0125aa in _dl_open () from /lib64/ld-linux-x86-64.so.2
#10 0x000000371f000f66 in dlopen_doit () from /lib64/libdl.so.2
#11 0x000000371e00e266 in _dl_catch_error () from
/lib64/ld-linux-x86-64.so.2
#12 0x000000371f00129c in _dlerror_run () from /lib64/libdl.so.2
#13 0x000000371f000ee1 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
#14 0x00007f48a4c87603 in
osgDB::DynamicLibrary::getLibraryHandle(std::string const&) () from
/projects/osg/release/lib64/libosgDB.so.130
#15 0x00007f48a4c87ba0 in osgDB::DynamicLibrary::loadLibrary(std::string
const&) () from /projects/osg/release/lib64/libosgDB.so.130
#16 0x00007f48a4cb5137 in osgDB::Registry::loadLibrary(std::string const&)
() from /projects/osg/release/lib64/libosgDB.so.130
#17 0x00007f48a4cba9c6 in
osgDB::Registry::read(osgDB::Registry::ReadFunctor const&) () from
/projects/osg/release/lib64/libosgDB.so.130
#18 0x00007f48a4cbb631 in
osgDB::Registry::readImplementation(osgDB::Registry::ReadFunctor const&,
osgDB::Options::CacheHintOptions) ()
   from /projects/osg/release/lib64/libosgDB.so.130
#19 0x00007f48a4cbbd5a in
osgDB::Registry::readObjectImplementation(std::string const&,
osgDB::Options const*) () from /projects/osg/release/lib64/libosgDB.so.130
#20 0x00007f48a4cac4e8 in osgDB::readRefObjectFile(std::string const&,
osgDB::Options const*) () from /projects/osg/release/lib64/libosgDB.so.130
#21 0x00007f48a58576a1 in osgText::readRefFontFile(std::string const&,
osgDB::Options const*) () from /projects/osg/release/lib64/libosgText.so.130
#22 0x00007f48a586ae4a in osgText::TextBase::setFont(std::string const&) ()
from /projects/osg/release/lib64/libosgText.so.130
#23 0x00007f48a7de6397 in
osgViewer::StatsHandler::setUpScene(osgViewer::ViewerBase*) () from
/projects/osg/release/lib64/libosgViewer.so.130
#24 0x00007f48a7deda3f in
osgViewer::StatsHandler::handle(osgGA::GUIEventAdapter const&,
osgGA::GUIActionAdapter&) () from
/projects/osg/release/lib64/libosgViewer.so.130
#25 0x00007f48a82f0192 in osgGA::GUIEventHandler::handle(osgGA::Event*,
osg::Object*, osg::NodeVisitor*) () from
/projects/osg/release/lib64/libosgGA.so.130
#26 0x00007f48a7e0af93 in osgViewer::Viewer::eventTraversal() () from
/projects/osg/release/lib64/libosgViewer.so.130
#27 0x00007f48a7e12979 in osgViewer::ViewerBase::frame(double) () from
/projects/osg/release/lib64/libosgViewer.so.130
#28 0x00007f48a61e7e6e in QWidget::event(QEvent*) () from
/projects/osg/release/lib64/libQtGui.so.4
#29 0x00007f48a6ca0d8c in QGLWidget::event(QEvent*) () from
/projects/osg/release/lib64/libQtOpenGL.so.4
#30 0x00007f48a619949c in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /projects/osg/release/lib64/libQtGui.so.4
#31 0x00007f48a619f981 in QApplication::notify(QObject*, QEvent*) () from
/projects/osg/release/lib64/libQtGui.so.4
#32 0x00007f48a5c4122c in QCoreApplication::notifyInternal(QObject*,
QEvent*) () from /projects/osg/release/lib64/libQtCore.so.4
#33 0x00007f48a61ea88c in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion
const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
   from /projects/osg/release/lib64/libQtGui.so.4
#34 0x00007f48a63b2b1c in QWidgetPrivate::repaint_sys(QRegion const&) ()
from /projects/osg/release/lib64/libQtGui.so.4
#35 0x00007f48a61ddf64 in QWidgetPrivate::syncBackingStore() () from
/projects/osg/release/lib64/libQtGui.so.4
#36 0x00007f48a61e83fc in QWidget::event(QEvent*) () from
/projects/osg/release/lib64/libQtGui.so.4
#37 0x00007f48a6ca0d8c in QGLWidget::event(QEvent*) () from
/projects/osg/release/lib64/libQtOpenGL.so.4
#38 0x00007f48a619949c in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /projects/osg/release/lib64/libQtGui.so.4
#39 0x00007f48a619f981 in QApplication::notify(QObject*, QEvent*) () from
/projects/osg/release/lib64/libQtGui.so.4
#40 0x00007f48a5c4122c in QCoreApplication::notifyInternal(QObject*,
QEvent*) () from /projects/osg/release/lib64/libQtCore.so.4
#41 0x00007f48a5c4530b in
QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
from /projects/osg/release/lib64/libQtCore.so.4
#42 0x00007f48a623d471 in ?? () from
/projects/osg/release/lib64/libQtGui.so.4
#43 0x00007f48a5c3ff12 in
QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from
/projects/osg/release/lib64/libQtCore.so.4
#44 0x00007f48a5c40274 in
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from
/projects/osg/release/lib64/libQtCore.so.4
#45 0x00007f48a5c456cb in QCoreApplication::exec() () from
/projects/osg/release/lib64/libQtCore.so.4
#46 0x0000000000412f5f in main (argc=1, argv=0x7ffec6063ec8) at main.cpp:96



On 21 September 2015 at 11:26, Robert Osfield <robert.osfield at gmail.com>
wrote:

> Hi Gareth,
>
> I don't recall this being an issue before.  What hardware, OS and
> OSG/osgEarth versions are you using?
>
> Robert.
>
> On 21 September 2015 at 11:15, Gareth Francis <gfrancis.dev at gmail.com>
> wrote:
>
>>
>> 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
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


-- 
--------------------
Gareth Francis
www.gfrancisdev.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150921/3bb04c9f/attachment-0003.htm>


More information about the osg-users mailing list