After compiling an application with clang 3.6 using -fsanitize=undefined, I'm trying to start the instrumented program while using a suppression file to ignore some of the errors:
UBSAN_OPTIONS="suppressions=ubsan.supp" ./app.exe
The suppression file ubsan.supp contains:
signed-integer-overflow:example.c
This leads to an error message:
UndefinedBehaviorSanitizer: failed to parse suppressions
The same occurs with a gcc 4.9 build. The only documentation I can find is http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html, which is for clang 3.9, while I use 3.6 (which doesn't have documentation for ubsan included).
Can anyone provide working examples for ubsan suppression files, that work in clang 3.6?
Edit: By browsing the source code of ubsan, I found that the only valid suppression type might be "vptr_check" - dunno which version I was looking at though. Can anyone confirm that in clang 3.9 more suppression types are available?
答案 0 :(得分:1)
我通过创建三个文件compile.sh
,main.cpp
和suppressions.supp
来尝试它,如下所示。 unsigned-integer-overflow
不是undefined
的一部分,因为它需要特别包含在内。这可以在我的机器上使用clang-3.9。
因此,我猜测更多抑制类型在clang-3.9
中有效。
# compile.sh
set -x
UBSAN_OPTIONS=suppressions=suppressions.supp:print_stacktrace=1 #:help=1
export UBSAN_OPTIONS
clang++-3.9 -g -std=c++11 -fsanitize=undefined -fno-omit-frame-pointer -fsanitize=unsigned-integer-overflow main.cpp
./a.out
// main.cpp
#include <bits/stdc++.h>
#include <bits/stl_tree.h>
using namespace std;
int main(int argc, char **argv) {
unsigned int k = UINT_MAX;
k += 1;
return 0;
}
# suppressions.supp
unsigned-integer-overflow:main.cpp
答案 1 :(得分:0)
我没有花时间确切地找出clang-3.6
中可用的抑制,但是似乎在clang-3.7
中只有vptr_check
可以用作抑制。从clang-3.8
开始,禁止列表为defined,将成为支票的list,外加vptr_check
。
在clang-3.9
中,支票available是: