Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by Crashy » Thu Sep 13, 2012 2:28 pm
Hi,
I'm having a very annoying bug, occuring randomly and only in release mode.
So, what's the problem? Sometimes, the frame after I set the force and torque callback of my rigidbody, some values (Omega, Velocity, id depends) are .#QNAN, .#INF or .#IND, and I really don't know what is the source of this error. I've checked multiple times for uninitialized variables, but I don't find any one.
The mass matrix and the transform matrix are set, and so is the initial velocity. I've also enabled all exceptions in visual studio to check for access violation and other similar things, but the bug is regular only when the program is launched outside of visual.
I've read some similar topics right here, but no one seems helpfull and I'm desperatly looking for some hints.
-
Crashy
-
- Posts: 101
- Joined: Fri Dec 03, 2010 6:30 am
by Julio Jerez » Thu Sep 13, 2012 3:03 pm
I do not know what could that be, but there is a class that let you set float exepction in the engine
it is in file source\core\dgTypes.h is class dgFloatExceptions, it looks like this
- Code: Select all
class dgFloatExceptions
{
public:
#define DG_FLOAT_EXECTIONS_MASK (_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE)
dgFloatExceptions()
:m_mask (0)
{
// #if (defined (_MSC_VER) && defined (_DEBUG))
// dgClearFP();
// m_mask = dgControlFP(0, 0);
// dgControlFP(m_mask & dgUnsigned32 (~DG_FLOAT_EXECTIONS_MASK), _MCW_EM);
// #endif
}
~dgFloatExceptions()
{
// #if (defined (_MSC_VER) && defined (_DEBUG))
// dgClearFP();
// dgControlFP(m_mask | dgUnsigned32(DG_FLOAT_EXECTIONS_MASK), _MCW_EM);
// #endif
}
dgInt32 m_mask;
};
the code is momentetd out because visual studio 64 bit do not let the client app set the state of the floats registers anymore in 64 bit.
it does let you do it is 32 but mode.
you can uncommnet teh comnted oput lien and see if you trap the exeception.
you can also copy the code and made your own class and you can use it for checking for expection in section of you code.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Crashy » Thu Sep 13, 2012 4:04 pm
I just have to uncomment and it will be enabled?
-
Crashy
-
- Posts: 101
- Joined: Fri Dec 03, 2010 6:30 am
by Julio Jerez » Thu Sep 13, 2012 4:52 pm
yes ucommnet teh liens and it will be on.
however if the nan is happening outside the code it will not detected,
because execptions is only on during the newtonUpdate, and it only works in 32 bit mode in Visual studio.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Crashy » Thu Sep 13, 2012 7:16 pm
Two things:
-I'm definitely unable to reproduce it in debug mode.
-to enable the floating point checks, I needed to sets the application to DG_USE_THREAD_EMULATION. And the bug is still here in release, so it's not a concurrency problem.
I also enabled /fp:except without any new information.
I've looked for code errors with cppcheck without any significant result apart from that constructor(and the one of dgTemplateVector too):
- Code: Select all
template<class T>
TemplateVector<T>::TemplateVector() {}
That I replaced by
- Code: Select all
template<class T>
TemplateVector<T>::TemplateVector():m_x(0),m_y(0),m_z(0) {}
But obviously it wasn't that as the bug is still here. I'll try IMB Purify tomorrow to see if it can help me.
-
Crashy
-
- Posts: 101
- Joined: Fri Dec 03, 2010 6:30 am
by Crashy » Fri Sep 14, 2012 7:09 am
MMh I think I've fixed it, I'm not sure as it is random but I cannot reproduce it. It was a quaternion that was not normalized, so the resulting orientation matrix was not orthonormed.
-
Crashy
-
- Posts: 101
- Joined: Fri Dec 03, 2010 6:30 am
by Julio Jerez » Fri Sep 14, 2012 9:40 am
there you go.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 5 guests