[osg-users] OpenThreads Mutex::lock() crash

Guy Volckaert guy.volckaert at meggitt.com
Thu Jul 12 11:50:39 PDT 2018


Has anyone experienced issues with OpenThreads Mutext::lock()? Occasionally a crash occurs when starting my application but only if the threading model is not SingleThreaded. The crash occurs in the following functions of OpenThreads:


int Mutex::lock() {
    Win32MutexPrivateData *pd =


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

    return 0;


What I noticed is that sometimes "pd" is 0 eventhough "_prvData" is not 0!! I can't understand how that can occur unless there's a concurency issue. As a test, I added a sanity check after initializing the "pb" local variable, as follows:


    while( pd == 0 )
        Sleep( 10 ); // sleep for 10ms and try again...
        pd = static_cast<Win32MutexPrivateData*>(_prvData);

I know it's dumb... but it works. I've been chasing this problem for a long time now and I haven't found a solution yet (except my dumb one). 

This issue occurs with v3.4.0 and v3.6.2. The crash occurs on Win7 and Win10 when build with VS2013. 

Any help on this topic would be much appreciated.

Thank you!


Read this topic online here:

More information about the osg-users mailing list