Philipp Claßen Philipp Claßen - 1 year ago 149
C++ Question

Avoiding false positives with clang's ThreadSanitizer and TBB

Has anyone tried clang's ThreadSanitizer with Intel Threading Building Blocks (TBB)?

My experience so far was that you will get a lot of warnings, even for relatively simple examples. Unfortunately, many of them seem to be false positives.

In this answer to another ThreadSanitizer question, suppression files are recommended. Could that help? Is there a suppression file for TBB or any other technique?

(Side note: With Helgrind, it looks similar. Many false positives.)

Answer Source

I only got it working when I reference the suppression file in TSAN_OPTIONS. At least for me, only referencing in during compilation with -fsanitize-blacklist did not work with the environment variable.

Anyway, here is a possible suppression file

# sanitizer-thread-suppressions.txt

... and that is how you can use it:

TSAN_OPTIONS="suppressions=sanitizer-thread-suppressions.txt" ./my_binary

If you increase verbosity, you should see outputs like these:

TSAN_OPTIONS="verbosity=2 suppressions=sanitizer-thread-suppressions.txt" ./my_binary
ThreadSanitizer: matched suppression '^tbb*'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download