Why Your Tests Still Miss C++ Bugs: Valgrind, Sanitizers, and Runtime Debugging
summary
Unit tests miss heap corruption, races, and UB that only show at runtime; the practical stack is Valgrind Memcheck (no rebuild, 10–50x slower, serializes threads, best uninitialized tracking, Linux-only), AddressSanitizer (rebuild required, 1 shadow byte per 8 bytes, catches heap and stack overflows, LeakSanitizer on Linux, works on GCC/Clang and MSVC VS2019+), ThreadSanitizer (happens‑before race detection, must execute the bad interleaving), and UBSan (cheap UB checks, can trap). Use ASan + UBSan as default debug build, run TSan/Valgrind in CI/nightly, fail on reports and add regression tests.
AI-written summary · about
chapters (16)
- 0:00Introduction and agenda
- 1:51Why tests miss runtime bugs
- 6:32Types of runtime bugs
- 7:58Valgrind vs sanitizers overview
- 9:00Deep dive into Valgrind
- 15:26Valgrind tools and pros cons
- 16:52AddressSanitizer explained
- 23:23ThreadSanitizer and UBSan
- 31:26Other sanitizers overview
- 32:31Tool comparison side by side
- 33:34Practical CI workflow
- 36:53Triage and fixing issues
- 38:17Suppression and false positives
- 38:39Embedded development tips
- 39:27Key takeaways summary
- 40:11Q&A session
