[osg-users] osgText crash

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


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:

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.


Read this topic online here:

More information about the osg-users mailing list