[osg-users] OSG crash on startup

Guy Volckaert guy.volckaert at meggitt.com
Wed Apr 26 10:07:44 PDT 2017


I was wondering if anyone observed a similar problems. In essence, we recently upgrade from v2.8.2 to 3.4.0 and we are now noticing random crashed when launching many of our applications. Note that we also upgraded from VS2005 to VS2013, so technically it can also be a compiler issue as well. Hopefully you guys can guide me a little towards where to investigate;)

I’ve been able to isolate the crash in Win32Mutex.cpp, the lock() and unlock() functions:


Mutex::Mutex(MutexType type):
    Win32MutexPrivateData *pd = new Win32MutexPrivateData();
    _prvData = static_cast<void *>(pd);

int Mutex::lock() {
    Win32MutexPrivateData *pd =
    [b]if(!pd) return 0; /////// ADDED THIS SANITY CHECK[/b]


    // Block until we can take this lock.
    EnterCriticalSection( &(pd->_cs) );

    return 0;



In essence, from time to time the <pd> pointer would be NULL even though <_prvData> is not, causing a crash when calling EnterCriticalSection(). I suspect that maybe there a racing condition when creating the internal threads. Adding if(!pd) return 0; seems to resolve the problem, albeit not a perfect solution.

Any ideas would be appreciated. 

Thank you!


Read this topic online here:

More information about the osg-users mailing list