3 ms·
> -fsanitize=address,undefined In addition, I recommend -fsanitize=integer. This adds checks for unsigned integer overflow which is well-defined but almost nev
by nwellnhof 4y ago
> -fsanitize=address,undefined
In addition, I recommend -fsanitize=integer. This adds checks for unsigned integer overflow which is well-defined but almost never what you want. It also checks for truncation and sign changes in implicit conversions which can be helpful to identify bugs. This doesn't work if you pepper your code base with explicit integer casts, though, which many have considered good practice in the past.
- hddqsb 4y agoGood one, thanks. Note that it requires Clang; GCC 12.2 doesn't have it.
- gavinray 4y agoWow nice, I didn't know about this one. I can add some more which are less known. This is my current sanitize invocation (minus the addition of "integer" which I'll be adding, unless one of these other ones covers it): -fsanitize=address,leak,undefined,cfi,function CFI has checks for unrelated casts and mismatched vtables which is very useful. It requires that you pass -flto or -flto=thin and -fvisibility=hidden. You can read a comparison with -fsanitize=function here: https://clang.llvm.org/docs/ControlFlowIntegrity.html#fsanitize-cfi-icall-and-fsanitize-function https://clang.llvm.org/docs/ControlFlowIntegrity.html#fsanit... There's also TypeSanitizer, which isn't officially released, but is really interesting and should be able to be applied via a patch from the branch: https://www.youtube.com/watch?v=vAXJeN7k32Y https://www.youtube.com/watch?v=vAXJeN7k32Y https://reviews.llvm.org/D32199 https://reviews.llvm.org/D32199 $ curl -L 'https://reviews.llvm.org/D32199?download=1' | patch -p1
- nwellnhof 4y agoI think "leak" is always enabled by "address". It's only useful if you want run LeakSanitizer in stand-alone mode. "integer" is only enabled on demand because it warns about well-defined (but still dangerous) code. You can also enable "unsigned-integer-overflow" and "implicit-conversion" separately. See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#...
- gavinray 4y agoAh I wasn't sure if LSAN was always enabled with ASAN, good to know -- ty!