Although pointer-bounds problems will be caught on exit, many times this mistake will cause the program to crash long before exit. If you suspect the problem may be due to memory corruption, put this line in your code before the crash:
Try to make it as close to the crash as possible. This causes all of the bounds checks described above to be made so it is a very slow call, too slow to call frequently even in a debug build. However, if memory has been corrupted, this call will usually find it. It is another good tool to help find memory corruption problems.