OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

OSG crash on startup


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
guyv
User


Joined: 13 Feb 2009
Posts: 88

PostPosted: Wed Apr 26, 2017 5:07 pm    Post subject:
OSG crash on startup
Reply with quote

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:
Back to top
View user's profile Send private message
loopy
User


Joined: 11 Mar 2009
Posts: 70

PostPosted: Thu May 11, 2017 5:20 pm    Post subject:
Reply with quote

What can happen is that if you are not careful you can end up using an incompatible mix of the following defines.

_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED
_OPENTHREADS_ATOMIC_USE_MUTEX


Just make sure you are using the same OpenThreads/Config header in your code as was used to build OSG.
Back to top
View user's profile Send private message
guyv
User


Joined: 13 Feb 2009
Posts: 88

PostPosted: Thu May 11, 2017 5:30 pm    Post subject:
Reply with quote

Understood. I compared the Config file used for building OSG and the one that is copied by the INSTALL project, which is used by my app, and they are both the same.

Below is the content of my OpenThreads\Config header file.

Code:

#ifndef _OPENTHREADS_CONFIG
#define _OPENTHREADS_CONFIG

/* #undef _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS */
/* #undef _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS */
/* #undef _OPENTHREADS_ATOMIC_USE_SUN */
#define _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED
/* #undef _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC */
/* #undef _OPENTHREADS_ATOMIC_USE_MUTEX */
/* #undef OT_LIBRARY_STATIC */

#endif


Thank you!

Cheers,
Guy
Back to top
View user's profile Send private message
loopy
User


Joined: 11 Mar 2009
Posts: 70

PostPosted: Thu May 11, 2017 7:29 pm    Post subject:
Reply with quote

Hi Guy,

I'm using OSG 3.4.0 with both VS 2013 and lately VS2015 and the only issue I had was the exactly what I described. It was my mistake, I was including the header from the distro, not the build area. And the symptoms were very similar to what you described. Sorry that's not it.

Andrew
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osg::Text::setBackdropType crash with... Carlo Lanzotti - DynaD... General 7 Wed Sep 20, 2017 2:40 pm View latest post
No new posts Fix for osg::Program crash Colin McDonald Submission 0 Mon Sep 11, 2017 4:43 pm View latest post
No new posts Crash with VBO and shared context jumaroch General 0 Tue Jul 25, 2017 1:24 pm View latest post
No new posts Crash with VBO and shared context jumaroch General 10 Tue Jul 25, 2017 1:23 pm View latest post
No new posts Crash on Windows 10 with a Display Li... efson General 2 Thu Apr 27, 2017 9:03 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP