Undefined behavior sanitizer suppression file: failed to parse suppressions
Asked Answered
O

2

7

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?

Orsino answered 4/3, 2016 at 17:55 Comment(0)
C
3

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"
Combings answered 31/12, 2018 at 19:20 Comment(0)
B
1

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
Bopp answered 5/7, 2017 at 19:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.