[osg-users] OSG crash on startup

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


Hi,

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:


Code:

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


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

#ifdef USE_CRITICAL_SECTION

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

    return 0;

#else 
[…]
#endif // USE_CRITICAL_SECTION

}



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!

Cheers,
Guy
Code:




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








More information about the osg-users mailing list