13

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.)

Community
  • 1
  • 1
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
  • 1
    Don't use atomics of any kind, as soon as you do, none of these tools seem to work well at all. – goji Oct 02 '13 at 01:09
  • 1
    I just posted another related question (libstdc++ atomics instead of tbb), if you're interested: http://stackoverflow.com/questions/19128549/force-use-of-locks-inside-stdatomic-during-debugging-with-libstdc – goji Oct 02 '13 at 01:21

1 Answers1

11

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
race:^tbb*

... 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*'

Please note that the pattern ^tbb* is simple but potentially dangerous as it might hide warnings in your own code. More realistic would be something like this:

race:^__interceptor_memset*
race:^tbb::interface9::internal::adaptive_mode*
race:^tbb::blocked_range*
race:^tbb::interface9::internal::start_for*
race:^tbb::internal::machine_load_store*
race:^tbb::strict_ppl::internal::micro_queue*
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239