[osg-users] osgText crash

Alexander Bobkov alexander.e.bobkov at gmail.com
Tue Apr 7 09:41:17 PDT 2015


Hi,

My osgEarth based application was crashing from time to time (3-4 times a day). It was not easy to debug. But eventually I've caught the problem place in Release with Debug info mode.

DatabasePager thread crashed in osgText/Font.cpp file in the function:


Code:
osg::ref_ptr<Font>& Font::getDefaultFont()
{
    static OpenThreads::Mutex s_DefaultFontMutex;
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_DefaultFontMutex);

    static osg::ref_ptr<Font> s_defaultFont = new DefaultFont;
    return s_defaultFont;
}



I suppose that scoped static variable initialization is not thread-safe.

Perhaps the s_DefaultFontMutex variable should be the global.

Regards,
Alexander

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63290#63290








More information about the osg-users mailing list