Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: use {UBSAN,ASAN}_OPTIONS to abort on error
c20991d added `-ftrapv`, presumably to to catch overflows in the CI, but this doesn't really work because UBSan overrides the trap: [/tmp]~> cat test.c #include <limits.h> int main(void) { int a = 5; a += INT_MAX; return 0; } [/tmp]~> gcc -fsanitize=undefined -ftrapv test.c -o test [/tmp]~> ./test || echo "FAIL" test.c:5:4: runtime error: signed integer overflow: 5 + 2147483647 cannot be represented in type 'int' `-fsanitize-trap` gives the wanted trapping behavior but it doesn't print any diagnostic message: [/tmp]~> gcc -fsanitize=undefined -fsanitize-trap test.c -o test [/tmp]~> ./test || echo "FAIL" zsh: illegal hardware instruction ./test FAIL it's best to use `{ASAN,UBSAN}_OPTIONS` env vars to configure it to abort on error. this prints diagnostic and also traps: [/tmp]~> gcc -fsanitize=undefined test.c -o test [/tmp]~> UBSAN_OPTIONS='abort_on_error=1:halt_on_error=1' ./test || echo "FAIL" test.c:5:4: runtime error: signed integer overflow: 5 + 2147483647 cannot be represented in type 'int' zsh: IOT instruction UBSAN_OPTIONS='abort_on_error=1:halt_on_error=1' ./test FAIL
- Loading branch information