[PATCH] D28836: [tsan] Provide API for libraries for race detection on custom objects
Kuba (Brecka) Mracek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 31 09:22:28 PST 2017
kubamracek added a comment.
Here's the output of the testcase from the patch (the "TEST3" scenario, which is the only one interesting). The stacks have some C++'ish noise in them due to the use of std::thread.
$ ./projects/compiler-rt/test/tsan/X86_64Config/Darwin/Output/external.cc.tmp-lib-noninstrumented-callbacks
RR test done
==================
WARNING: ThreadSanitizer: race on a library object (pid=13155)
Mutating access of object MyLibrary::MyObject at 0x7b04000000a0 by thread T4:
#0 ObjectWrite external.cc:73 (external.cc.tmp-lib-noninstrumented-callbacks.dylib:x86_64+0xea2)
#1 main::$_3::operator()() const external.cc:106 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x10000771f)
#2 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, main::$_3> >(void*) thread:346 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x1000073f0)
Previous read-only access of object MyLibrary::MyObject at 0x7b04000000a0 by thread T3:
#0 ObjectRead external.cc:66 (external.cc.tmp-lib-noninstrumented-callbacks.dylib:x86_64+0xe5e)
#1 main::$_2::operator()() const external.cc:105 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100005fa8)
#2 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, main::$_2> >(void*) thread:346 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100005c80)
Location is MyLibrary::MyObject object of size 16 at 0x7b04000000a0 allocated by main thread:
#0 malloc sanitizer_malloc_mac.inc:134 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x44d27)
#1 ObjectCreate external.cc:57 (external.cc.tmp-lib-noninstrumented-callbacks.dylib:x86_64+0xe03)
#2 start <null>:94378568 (libdyld.dylib:x86_64+0x5234)
Thread T4 (tid=13251813, running) created by main thread at:
#0 pthread_create tsan_interceptors.cc:897 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x27dce)
#1 std::__1::thread::thread<main::$_3, void>(main::$_3&&) thread:362 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x1000069e2)
#2 std::__1::thread::thread<main::$_3, void>(main::$_3&&) thread:354 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x1000017b8)
#3 main external.cc:106 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100001434)
Thread T3 (tid=13251812, finished) created by main thread at:
#0 pthread_create tsan_interceptors.cc:897 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x27dce)
#1 std::__1::thread::thread<main::$_2, void>(main::$_2&&) thread:362 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100005272)
#2 std::__1::thread::thread<main::$_2, void>(main::$_2&&) thread:354 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100001758)
#3 main external.cc:105 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x10000141a)
SUMMARY: ThreadSanitizer: race on a library object external.cc:73 in ObjectWrite
==================
RW test done
==================
WARNING: ThreadSanitizer: race on a library object (pid=13155)
Mutating access of object MyLibrary::MyObject at 0x7b04000000f0 by thread T6:
#0 ObjectWriteAnother external.cc:80 (external.cc.tmp-lib-noninstrumented-callbacks.dylib:x86_64+0xef2)
#1 main::$_5::operator()() const external.cc:132 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x10000a5ff)
#2 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, main::$_5> >(void*) thread:346 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x10000a2d0)
Previous mutating access of object MyLibrary::MyObject at 0x7b04000000f0 by thread T5:
#0 ObjectWrite external.cc:73 (external.cc.tmp-lib-noninstrumented-callbacks.dylib:x86_64+0xea2)
#1 main::$_4::operator()() const external.cc:131 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100008e8f)
#2 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, main::$_4> >(void*) thread:346 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100008b60)
Location is MyLibrary::MyObject object of size 16 at 0x7b04000000f0 allocated by main thread:
#0 malloc sanitizer_malloc_mac.inc:134 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x44d27)
#1 ObjectCreate external.cc:57 (external.cc.tmp-lib-noninstrumented-callbacks.dylib:x86_64+0xe03)
#2 start <null>:94378568 (libdyld.dylib:x86_64+0x5234)
Thread T6 (tid=13251870, running) created by main thread at:
#0 pthread_create tsan_interceptors.cc:897 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x27dce)
#1 std::__1::thread::thread<main::$_5, void>(main::$_5&&) thread:362 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x1000098c2)
#2 std::__1::thread::thread<main::$_5, void>(main::$_5&&) thread:354 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100001878)
#3 main external.cc:132 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x1000014fb)
Thread T5 (tid=13251869, finished) created by main thread at:
#0 pthread_create tsan_interceptors.cc:897 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x27dce)
#1 std::__1::thread::thread<main::$_4, void>(main::$_4&&) thread:362 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100008152)
#2 std::__1::thread::thread<main::$_4, void>(main::$_4&&) thread:354 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x100001818)
#3 main external.cc:131 (external.cc.tmp-lib-noninstrumented-callbacks:x86_64+0x1000014d8)
SUMMARY: ThreadSanitizer: race on a library object external.cc:80 in ObjectWriteAnother
==================
WW test done
ThreadSanitizer: reported 2 warnings
https://reviews.llvm.org/D28836
More information about the llvm-commits
mailing list