Undefined behavior sanitizer suppression file: failed to parse suppressions

时间:2016-03-04 17:55:09

标签: clang sanitizer ubsan

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?

2 个答案:

答案 0 :(得分:1)

我通过创建三个文件compile.shmain.cppsuppressions.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是:

  • “未定义”
  • “空”
  • “指针使用错误”
  • “对齐”
  • “对象大小”
  • “签名整数溢出”
  • “无符号整数溢出”
  • “整数除以零”
  • “浮点除零”
  • “基于班次”
  • “移位指数”
  • “界限”
  • “无法到达”
  • “返回”
  • “ vla绑定”
  • “浮动广播溢出”
  • “布尔”
  • “枚举”
  • “功能”
  • “返回非空属性”
  • “ nonnull属性”
  • “ vptr”
  • “ cfi”
  • “ vptr_check”