Breakpoint exceptions from the heap

New programmers sometimes ask why the debugger stopped at a ‘user breakpoint’ exception in their program. The exception dialog will come up and say something like:

Unhandled exception at 0x77f75a58 in CoruptHeap.exe: User breakpoint.

The callstack might be something like:

ntdll.dll!77f75a58()   
ntdll.dll!77f9cb5e()   
ntdll.dll!77f82c95()   
ntdll.dll!77f9cf55()   
ntdll.dll!77f8c366()   
kernel32.dll!77e75b6c()        
kernel32.dll!77e6c75a()

Or if you have symbols:

ntdll.dll!_DbgBreakPoint@0()
ntdll.dll!RtlpBreakPointHeap(void *)
ntdll.dll!RtlpValidateHeapEntry(_HEAP *, _HEAP_ENTRY *, char *) 
ntdll.dll!RtlDebugFreeHeap(void *, unsigned long, void *)
ntdll.dll!RtlFreeHeapSlowly(void *, unsigned long, void *)
ntdll.dll!RtlFreeHeap(void *, unsigned long, void *)

The problem is that your program has corrupted the heap. This usually happens when writing to freed memory, or when writing past the end of a buffer. Use pageheap to try and figure out where your program went wrong.