🔒 Locked
buffer overwrite debugging in VC++
Advertisement
Original Post
Hi, i noticed that sometimes one of the variables that I'm printing out gets a value of something like #FD. i think that this means that I'm over writing something and it's flowing into my var - is this right? How do i debug this in VC++? Thanks.
Ok, the debugger said that I got an access violation and stopped at this code from the stl code:
I did it again and it was here:
what does this mean?
Thanks.
inline void __CLR_OR_THIS_CALL _Container_base::_Orphan_all() const { // orphan all iterators _Lockit _Lock(_LOCK_DEBUG); if (_Myfirstiter != _IGNORE_MYITERLIST) { for (_Iterator_base **_Pnext = (_Iterator_base **)&_Myfirstiter; *_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter) (*_Pnext)->_Mycont = 0; *(_Iterator_base **)&_Myfirstiter = 0; } }I did it again and it was here:
// TEMPLATE FUNCTION _Destroy_rangetemplate<class _Ty, class _Alloc> inline void _Destroy_range(_Ty *_First, _Ty *_Last, _Alloc& _Al) { // destroy [_First, _Last) _Destroy_range(_First, _Last, _Al, _Ptr_cat(_First, _Last)); }what does this mean?
Thanks.
What does that mean? What is "using a deallocated variable"?
Thanks.
Thanks.
This means that the area of memory that you use does not belong to you. Either you have a pointer that points to somewhere it shouldn't, or you allocated memory, used it, deallocated it and used it again (either with new, or as part of a container).
Of course, there is still the probability that you have a non-deterministic bug in your code that randomly bombs areas of memory through overflows. Did you do that watch thing I told you about?
Of course, there is still the probability that you have a non-deterministic bug in your code that randomly bombs areas of memory through overflows. Did you do that watch thing I told you about?
Thanks, how do you set a watch on a variable without setting a breakpoint?
Thanks.
Thanks.
the standard VC++ debugger.
Thanks.
Thanks.
Ok, I did the watch variable and found the lines that make the problem, they are:
could that cause a problem?
Thanks.
m_vCollisions.Body1->m_MyState.AngularVelocity += (Impulse/state_a.MomentOfInertia)*(R_ap.Dot(Normal)); m_vCollisions.Body2->m_MyState.AngularVelocity -= (Impulse/state_b.MomentOfInertia)*(R_bp.Dot(Normal));could that cause a problem?
Thanks.
-yes
-yes
I still can't figure out what the problem is:(
When it gets to th\t line it doesn't always crash, it seems to crash sort of randomly. What could this mean?
Thanks.
-yes
I still can't figure out what the problem is:(
When it gets to th\t line it doesn't always crash, it seems to crash sort of randomly. What could this mean?
Thanks.
What version of VC++ are you using? VC2005's STL implementation will break to the debugger if you access an invalid location in the vector, which pre-VC2005 STL implementations don't do.
It's usually impossible to tell if one line of code is going to cause a problem, it like saying "Have I used to correct version of the word 'there'?" - It's absolutely impossible to tell without some sort of context.
It's usually impossible to tell if one line of code is going to cause a problem, it like saying "Have I used to correct version of the word 'there'?" - It's absolutely impossible to tell without some sort of context.
I'm using Express - 2005. I got this on msdn:
What is the InitInstance function and were do I find it?
Thanks.
Quote:
To use the debug build to check for memory overwrite, you must first rebuild your project for debug. Then, go to the very beginning of your application's InitInstance function and add the following line:
afxMemDF |= checkAlwaysMemDF;
What is the InitInstance function and were do I find it?
Thanks.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement