I have some code in MS VC++ 6.0 that I am debugging. For some reason, at this certain point where I am trying to delete some dynamically allocated memory, it breaks and I get a pop up message box saying ‘User Breakpoint called from code at blah blah’.. then the Disassembly window pops up and I see
*memory address* int 3
The odd thing is, there is NOWHERE in the code that I am calling an assembly instruction like this (I think asm int 3 is a hardware break command for x86?)..
what could be causing this?
EDIT: ANSWER: My code was ‘walking off the end’ of an array, but only in the locations marked by Visual Studio debug with 0xFDFDFDFD, which is called a NoMan’sLand fence.. I think its also called an Off-by-one error.. This array was unrelated to the point where i was freeing the memory when the error was occuring. Which made it harder to spot.. 🙁
You’re probably hitting code in the debug heap routines that have found heap corruption.
What does the call stack look like when you’ve hit the Int 3?
Edit: Based on the stack trace in your comments, the routine
_CrtIsValidHeapPointer()is saying that the pointer being freed is bad. Here’s the snippet of code from MSVC’s DBGHEAP.C source:pUserDatawould be the value of the pointer you’re deleteing.