One of the very cool things about the Visual Studio Team System 2005 release is that it includes a number of tools for code robustness that were developed for internal use at Microsoft.  Many of the same tools that the Windows team and others use to improve their code quality are available to the broader community.

One of the niftier tools is App Verifier.  I just happened to stumble across the docs for this tool in MSDN, so I figured I'd throw a link here for those who haven't heard of it before.  App Verifier helps you catch heap corruption, lock contention/corruption, and invalid handles.

App Verifier does its magic at runtime, but there is also a cool suite of static code analysis tools (for both native C++, as well as managed code)