assertion thread sanity check

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

assertion thread sanity check

Postby tanzfisch » Fri Apr 15, 2016 1:44 pm

Hi,

I have multiple threads and create a newton world in each one of them.
In Release mode everything works as expected but in debug I get a strange assertion.

dgMemory.cpp line 469
!m_threadSanityCheck

Can someone explain me what triggers the exception?!
Maybe I doe something wrong in the creation order? Right now I have 2 worlds used by the main thread and some more in each in an other separate thread. The ones in the main thread are created first.

Thanks

Martin
tanzfisch
 
Posts: 34
Joined: Fri Feb 05, 2016 5:17 am

Re: assertion thread sanity check

Postby Julio Jerez » Fri Apr 15, 2016 3:34 pm

That assert is harmless, I put some assert like that to track things that should not happens but that may happen very rarely.
and example for that is some one allocation a large chunk of memory form a callback, the engine does no have control over that but a good application should not do that. so I ad those traps to rice an asset when it happens.

the engine memory manger is very, very good ad dealing with small memory chunks, but is no good at handling large memory chunks. all large allocation should done on initialization. this si usually a good practice.

In your case is a little different because you have multiple words, each work is doing it own global allocation out of order, so you will have that assert hitting some time.

Code: Select all
#ifdef _DEBUG
dgInt32 m_threadSanityCheck = 0;
#define DG_MEMORY_THREAD_SANITY_CHECK_LOCK()      \
   dgAssert (!m_threadSanityCheck);            \
   dgAtomicExchangeAndAdd(&m_threadSanityCheck, 1);
   #define DG_MEMORY_THREAD_SANITY_CHECK_UNLOCK()     dgAtomicExchangeAndAdd(&m_threadSanityCheck, -1);   
#else
   #define DG_MEMORY_THREAD_SANITY_CHECK_LOCK()
   #define DG_MEMORY_THREAD_SANITY_CHECK_UNLOCK()
#endif


I think we can remove the condition now and make so that the allocation is always thread safe.
how often do you get the assert?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: assertion thread sanity check

Postby tanzfisch » Sat Apr 16, 2016 12:24 pm

Right now it happens every single time I start.
But it's good to know that this is not a problem.

I use the worlds in the other threads for generating tree collisions parallel to the main thread so it does not affect the rendering and it works real great.
I had also a look in to User Meshs but this seems way too much effort for me now.
tanzfisch
 
Posts: 34
Joined: Fri Feb 05, 2016 5:17 am

Re: assertion thread sanity check

Postby tanzfisch » Mon May 09, 2016 6:39 am

I fixed it by preventing my code to create more than one world at a time using a simple mutex. Works fine for me.
tanzfisch
 
Posts: 34
Joined: Fri Feb 05, 2016 5:17 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 51 guests