Using sanitizers
Depending on your experience, you may already be familiar with the usage of sanitizers. If you’re not familiar with them, then this section is for you!
Sanitizers consist of instrumentation that’s automatically injected into your program by the compiler. This instrumentation is used to catch issues such as race conditions, memory leaks, and more.
If your compiler behaves in nondeterministic ways, using a sanitizer may be a good idea as you can take the pulse of the health of your system. Generally speaking, running your compiler with sanitizers enabled from time to time is a good idea.
To enable sanitizers, assuming you’re using Clang as the compiler toolchain, you only need to use -fsanitize=typeOfSanitizer
, where typeOfSanitizer
is one of the following:
address
: Detects invalid address accesses – for instance, use-after-free, out-of-bounds access, and so onmemory
: Detects access to valid addresses that haven...