Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined behavior sanitizer suppression file: failed to parse suppressions

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?

like image 969
nucleon Avatar asked Mar 04 '16 17:03

nucleon


2 Answers

I'd tried it by creating three files, compile.sh, main.cpp and suppressions.supp as shown below. The unsigned-integer-overflow is not a part of undefined that's why it needs to be included specifically. This works on my machine with clang-3.9.

So, I'd guess more suppression types are valid in 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
like image 172
Satyaanveshi Avatar answered Nov 03 '22 14:11

Satyaanveshi


I didn't spend the time to find out exactly which suppressions were available in clang-3.6, but it appears that in clang-3.7 only vptr_check is available as a suppression. Starting in clang-3.8, the suppressions list is defined to be the list of checks, plus vptr_check. In clang-3.9 the checks available are:

  • "undefined"
  • "null"
  • "misaligned-pointer-use"
  • "alignment"
  • "object-size"
  • "signed-integer-overflow"
  • "unsigned-integer-overflow"
  • "integer-divide-by-zero"
  • "float-divide-by-zero"
  • "shift-base"
  • "shift-exponent"
  • "bounds"
  • "unreachable"
  • "return"
  • "vla-bound"
  • "float-cast-overflow"
  • "bool"
  • "enum"
  • "function"
  • "returns-nonnull-attribute"
  • "nonnull-attribute"
  • "vptr"
  • "cfi"
  • "vptr_check"
like image 1
benf Avatar answered Nov 03 '22 12:11

benf