2

Clang には-fsanitize-blacklist、ThreadSanitizer からの警告を抑制するコンパイル スイッチがあります。残念ながら、私はそれを機能させることができません。

抑制したい例を次に示します。

WARNING: ThreadSanitizer: data race (pid=21502)
  Read of size 8 at 0x7f0dcf5b31a8 by thread T6:
    #0 tbb::interface6::internal::auto_partition_type_base<tbb::interface6::internal::auto_partition_type>::check_being_stolen(tbb::task&) /usr/include/tbb/partitioner.h:305 (exe+0x000000388b38)
    #1 <null> <null>:0 (libtbb.so.2+0x0000000224d9)

  Previous write of size 8 at 0x7f0dcf5b31a8 by thread T1:
    #0 auto_partition_type_base /usr/include/tbb/partitioner.h:299 (exe+0x000000388d9a)
    #1 <null> <null>:0 (libtbb.so.2+0x0000000224d9)
    #2 GhostSearch::Ghost3Search::SearchTask::execute_impl() /home/phil/ghost/search/ghost3/ghost3_search_alg.cpp:1456 (exe+0x000000387a8a)
    #3 <null> <null>:0 (libtbb.so.2+0x0000000224d9)
    #4 GhostSearch::Ghost3Search::Ghost3SearchAlg::NullWindowSearch(int, MOVE, int, std::vector<MOVE, std::allocator<MOVE> >&) /home/phil/ghost/search/ghost3/ghost3_search_alg.cpp:1640 (exe+0x000000388310)
    #5 GhostSearch::PureMTDSearchAlg::FullWindowSearch(GhostSearch::SearchWindow, GhostSearch::SearchWindow, MOVE, int, std::vector<MOVE, std::allocator<MOVE> >&) /home/phil/ghost/search/pure_mtd_search_alg.cpp:41 (exe+0x000000370e3f)
    #6 GhostSearch::PureSearchAlgWrapper::RequestHandlerThread::EnterHandlerMainLoop() /home/phil/ghost/search/pure_search_alg_wrapper.cpp:124 (exe+0x000000372d1b)
    #7 operator() /home/phil/ghost/search/pure_search_alg_wrapper.cpp:94 (exe+0x000000374683)
    #8 execute_native_thread_routine /home/phil/tmp/gcc/src/gcc-4.8-20130725/libstdc++-v3/src/c++11/thread.cc:84 (libstdc++.so.6+0x0000000b26cf)

  Thread T6 (tid=21518, running) created by thread T3 at:
    #0 pthread_create ??:0 (exe+0x0000002378e1)
    #1 <null> <null>:0 (libtbb.so.2+0x0000000198c0)

  Thread T1 (tid=21513, running) created by main thread at:
    #0 pthread_create ??:0 (exe+0x0000002378e1)
    #1 __gthread_create /home/phil/tmp/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu/bits/gthr-default.h:662 (libstdc++.so.6+0x0000000b291e)
    #2 GhostSearch::PureSearchAlgWrapper::StartRequestHandlerThread() /home/phil/ghost/search/pure_search_alg_wrapper.cpp:77 (exe+0x0000003715c3)
    #3 GhostSearch::Search::ExecuteSearch(GhostSearch::SEARCH_SETTINGS const&) /home/phil/ghost/search.cpp:243 (exe+0x00000033063f)
    #4 GhostSearch::Search::StartSearch(GhostSearch::SEARCH_SETTINGS const&, UserBoard const&, GhostInterfaces::UserInterface*) /home/phil/ghost/search.cpp:176 (exe+0x00000033037a)
    #5 GhostInterfaces::UserInterface::StartSearch(GhostSearch::SEARCH_SETTINGS const&, UserBoard const&) /home/phil/ghost/interface.cpp:1072 (exe+0x0000002ea220)
    #6 GhostInterfaces::UserInterface::MainLoop() /home/phil/ghost/interface.cpp:576 (exe+0x0000002e9464)
    #7 GhostInterfaces::Command_Analyze::Execute(GhostInterfaces::UserInterfaceData&) /home/phil/ghost/commands.cpp:1005 (exe+0x00000028756c)
    #8 GhostInterfaces::UserInterface::FinishNextCommand() /home/phil/ghost/interface.cpp:1161 (exe+0x0000002e9ed0)
    #9 GhostInterfaces::UserInterface::MainLoop() /home/phil/ghost/interface.cpp:571 (exe+0x0000002e9447)
    #10 main /home/phil/ghost/ghost.cpp:54 (exe+0x000000274efd)

SUMMARY: ThreadSanitizer: data race /usr/include/tbb/partitioner.h:305 tbb::interface6::internal::auto_partition_type_base<tbb::interface6::internal::auto_partition_type>::check_being_stolen(tbb::task&)

これまでのところ、抑制ファイルを試しています(ただし、機能しません):

# TBB
fun:tbb::*
src:/usr/include/tbb/partitioner.h

なぜうまくいかないのか知っていますか?

(ちなみに、TBB ライブラリからのすべての警告を抑制できれば幸いです。)

4

1 に答える 1

4

最後に、私はそれを働かせました。

ドキュメントによると、各行は有効な「suppression_type」( racethreadmutexsignaldeadlockまたはcalled_from_lib) で始まる必要があります。

私の例では、正しいサプレッション タイプはraceです。

これは、データ競合を含むことが知られている 2 つの関数を抑制する「sanitizer-thread-suppressions.txt」というファイルの例です。

race:Function1
race:MyNamespace::Function2

抑制ファイルをテストするには、TSAN_OPTIONS環境変数を設定し、アプリケーションを呼び出します (でコンパイルされます-fsanitize=thread)。

$ TSAN_OPTIONS="suppressions=sanitizer-thread-suppressions.txt" ./myapp

それが機能する場合は、コンパイル時に設定を適用できます。

-fsanitize=thread -fsanitize-blacklist=sanitizer-thread-suppressions.txt

于 2015-04-19T00:43:40.133 に答える