A long time ago when I was doing C++ work on Windows, there was an advanced diagnostics tool for debugging buffer overflows. It initialized all allocated memory areas, stack or heap, with a special pattern of characters so it could detect buffer overflows. It injected itself into the memory manager to do this and also so it could check all memory areas after a memory write to look for corruption. In exhaustive mode, it would do this after every memory write, not just in specific areas.
It made your program run horrendously slow of course, but it was a lifesaver for finding corrupted memory regions. Is there such a tool for Visual Studio 2013?
If found this SO post where one of the answers mentioned Application Verifier, but that's for a really old version of Visual Studio:
There's a few useful tools for debugging buffer overflows and other memory corruption issues that are either included out of the box with Visual Studio or are available as free downloads from Microsoft:
- CRT Debug Heap (this may be what you were thinking of from your description).
- Application Verifier is now part of the Debugging Tools for Windows, download from the 'Standalone Debugging Tools for Windows (WinDbg)' link towards the bottom of that page. The 'page heap' functionality of the heap verifier is a very powerful tool for finding buffer overflows on the heap.
- /GS and /sdl compiler options.
Outside of Windows, valgrind and clang's Address Sanitizer are both powerful tools.
来源:https://stackoverflow.com/questions/32240453/tool-to-debug-buffer-overflows-in-c-program-with-visual-studio