* Tim Wilson-Brown <
teor...@gmail.com>, 2015-08-07, 20:12:
>Under clang, the following arguments cause a trap or abort respectively on
>undefined behaviour.
>
>-fsanitize-undefined-trap-on-error
This option exists at least since clang 3.4, but seems broken in early versions:
$ clang -fsanitize=undefined -fsanitize-undefined-trap-on-error test.c
clang: error: invalid argument '-fsanitize=undefined' not allowed with '-fsanitize-undefined-trap-on-error'
But then -fsanitize-undefined-trap-on-error doesn't do anything without
-fsanitize=undefined...
It works correctly in clang >= 3.7 and in GCC >= 5.
Unfortunately, this option disables error messages. This doesn't matter for
fuzzing, but makes triaging UB crashes unnecessarily hard. :\
>-fno-sanitize-recover=all
This option works in clang >= 3.6 and in GCC >= 5.
But it makes the program exit with status 1, which is unhelpful for fuzzing. :(
The good news is that if your UBSan runtime is new enough[*], you don't need
any extra compiler options. Instead, you put this in environment:
UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1
Then you get both an error message and abort() on error.
[*] GCC >= 6.0 or LLVM >= 3.8, I believe.
--
Jakub Wilk