[llvm-dev] Suppress specific sanitizer check, but still fail program on all others
Laurenz Altenmüller via llvm-dev
llvm-dev at lists.llvm.org
Wed Mar 3 12:28:04 PST 2021
Hello,
I have a question regarding the sanitizers. I would like to suppress one
error in a third-party library, but still have the program exit 1 on any
other failed check. It seems to me that -fno-sanitize-recover will exit
the program regardless of the suppressions file's contents. With
-fsanitize-recover on the other hand, the specified error is correctly
suppressed and the other one still printed, but the program exits
normally, which I don't want.
$ cat main.cpp
int main() {
int k = 0x7fffffff;
k++; // signed-integer-overflow
k <<= k; // invalid-shift-exponent
return 0;
}
$ clang++ -fsanitize=undefined -fno-sanitize-recover main.cpp -o main
$ cat supp.txt
signed-integer-overflow:main.cpp
$ UBSAN_OPTIONS=report_error_type=1,suppressions=supp.txt ./main
main.cpp:3:4: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: signed-integer-overflow main.cpp:3:4 in
$ echo $?
1
$ clang++ -fsanitize=undefined -fsanitize-recover main.cpp -o main
$ UBSAN_OPTIONS=report_error_type=1,suppressions=supp.txt ./main
main.cpp:4:5: runtime error: shift exponent -2147483648 is negative
SUMMARY: UndefinedBehaviorSanitizer: invalid-shift-exponent main.cpp:4:5 in
$ echo $?
0
How can I achieve the desired behavior? Are Ubsan suppressions and
-fno-sanitize-recover really mutually exclusive?
Cheers
Laurenz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210303/5d2304db/attachment-0001.html>
More information about the llvm-dev
mailing list