MSVC 6 & breakpoints

Started by
2 comments, last by FXO 20 years ago
Hello! My software has a really nasty bug. (a memory leak that writes over other important data, that is also allocated by my program) I wanna see when the data is changed, so I can find the leak. When I set a breakpoint at the data that is changed, I get this after a while: "Unhandled exception in cn.exe (KERNEL32.DLL) 0xC0000005: Access Violation" Its really hard to find from where and when my data is overwritten without the data-change-breakpoint. Does anybody have any idea on what to do? Thanks a ton /FXO
Advertisement
Start single-stepping through somewhere "earlier" in the program, the function that calls the one at fault, or even at the beginning of the program. You''ll be able to see exactly what''s up.
You can add catch blocks to try and figure it out, or you can investigate your code to figure out why you might have an access violation.

One gotcha is often passing objects by value instead of reference and having no appropriate copy constructor. This means that the object is having a memcpy''d version of it created and then destroyed. If you have pointers in your object, then the destructor for your class will probably delete the memory the pointers point to and when you return from the function the integrity of the object will have been breached.

A quick way to find out if this is happening is to use trace statements in your destructors.
"You can add catch blocks.."
-Its when I add catch blocks that I get the
"Unhandled exception in cn.exe (KERNEL32.DLL) 0xC0000005: Access Violation"
Its kinda sucky, there is a lot of code and even if I had the line of code that wrote over the memory infront of me,
I dont think I would see it, because all I have to go on is the memory adress..

"A quick way to find out if this is happening is to use trace statements in your destructors. "
How will this help me find when my memory is overwritten?
All I know is the adress of the memory that is changed.

If only I could set a break when the memory is changed, it would be a no-brainer.

This topic is closed to new replies.

Advertisement