odyaka341 / thread-sanitizer

Automatically exported from code.google.com/p/thread-sanitizer
0 stars 0 forks source link

TSan should correctly synchronize the TSD destructors and the parent thread #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$ TSAN_OPTIONS="history_size=7 
external_symbolizer_path=third_party/llvm-build/Release+Asserts/bin/llvm-symboli
zer" out/Release/base_unittests 
--gtest_filter=ThreadCollisionTest.MTB*:ThreadLocalStorageTest.TLS*
Note: Google Test filter = ThreadCollisionTest.MTB*:ThreadLocalStorageTest.TLS*
[==========] Running 2 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 1 test from ThreadLocalStorageTest
[ RUN      ] ThreadLocalStorageTest.TLSDestructors
[       OK ] ThreadLocalStorageTest.TLSDestructors (98 ms)
[----------] 1 test from ThreadLocalStorageTest (99 ms total)

[----------] 1 test from ThreadCollisionTest
[ RUN      ] ThreadCollisionTest.MTBookCriticalSectionTest
==================
WARNING: ThreadSanitizer: data race (pid=6979)
  Write of size 8 at 0x7fff1da08148 by main thread:
    #0 ThreadCollisionTest_MTBookCriticalSectionTest_Test::TestBody() /usr/local/google/chrome-asan/src/out/Release/../../base/threading/thread_collision_warner_unittest.cc:163 (base_unittests+0x0000004fb113)
    #1 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2051 (base_unittests+0x0000005cf26e)
    #2 testing::Test::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2067 (base_unittests+0x0000005cf0d0)
    #3 testing::TestInfo::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2244 (base_unittests+0x0000005cfe06)
    #4 testing::TestCase::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2351 (base_unittests+0x0000005d07e8)
    #5 testing::internal::UnitTestImpl::RunAllTests() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:4177 (base_unittests+0x0000005d8734)
    #6 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2051 (base_unittests+0x0000005d7ffe)
    #7 testing::UnitTest::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:3810 (base_unittests+0x0000005d7ecd)
    #8 base::TestSuite::Run() /usr/local/google/chrome-asan/src/out/Release/../../base/test/test_suite.cc:195 (base_unittests+0x000000818117)
    #9 main /usr/local/google/chrome-asan/src/out/Release/../../base/test/run_all_unittests.cc:10 (base_unittests+0x0000006a08b8)

  Previous read of size 4 at 0x7fff1da0814c by thread T4:
    #0 base::(anonymous namespace)::ThreadLocalStorageCleanup(void*) /usr/local/google/chrome-asan/src/out/Release/../../base/threading/thread_local_storage_unittest.cc:64 (base_unittests+0x0000004fd7c4)
    #1 start_thread <null>:0 (libpthread.so.0+0x000000006a60)

==================
==================
WARNING: ThreadSanitizer: data race (pid=6979)
  Write of size 8 at 0x7fff1da08140 by main thread:
    #0 scoped_ptr /usr/local/google/chrome-asan/src/out/Release/../../base/memory/scoped_ptr.h:147 (base_unittests+0x0000004fb123)
    #1 scoped_ptr /usr/local/google/chrome-asan/src/out/Release/../../base/memory/scoped_ptr.h:147 (base_unittests+0x0000004fb123)
    #2 NonThreadSafeQueue /usr/local/google/chrome-asan/src/out/Release/../../base/threading/thread_collision_warner_unittest.cc:131 (base_unittests+0x0000004fb123)
    #3 ThreadCollisionTest_MTBookCriticalSectionTest_Test::TestBody() /usr/local/google/chrome-asan/src/out/Release/../../base/threading/thread_collision_warner_unittest.cc:165 (base_unittests+0x0000004fb123)
    #4 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2051 (base_unittests+0x0000005cf26e)
    #5 testing::Test::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2067 (base_unittests+0x0000005cf0d0)
    #6 testing::TestInfo::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2244 (base_unittests+0x0000005cfe06)
    #7 testing::TestCase::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2351 (base_unittests+0x0000005d07e8)
    #8 testing::internal::UnitTestImpl::RunAllTests() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:4177 (base_unittests+0x0000005d8734)
    #9 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:2051 (base_unittests+0x0000005d7ffe)
    #10 testing::UnitTest::Run() /usr/local/google/chrome-asan/src/out/Release/../../testing/gtest/src/gtest.cc:3810 (base_unittests+0x0000005d7ecd)
    #11 base::TestSuite::Run() /usr/local/google/chrome-asan/src/out/Release/../../base/test/test_suite.cc:195 (base_unittests+0x000000818117)
    #12 main /usr/local/google/chrome-asan/src/out/Release/../../base/test/run_all_unittests.cc:10 (base_unittests+0x0000006a08b8)

  Previous read of size 4 at 0x7fff1da08140 by thread T1:
    #0 base::(anonymous namespace)::ThreadLocalStorageCleanup(void*) /usr/local/google/chrome-asan/src/out/Release/../../base/threading/thread_local_storage_unittest.cc:64 (base_unittests+0x0000004fd7c4)
    #1 start_thread <null>:0 (libpthread.so.0+0x000000006a60)

==================
[       OK ] ThreadCollisionTest.MTBookCriticalSectionTest (136 ms)
[----------] 1 test from ThreadCollisionTest (136 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 2 test cases ran. (235 ms total)
[  PASSED  ] 2 tests.

Because the TLSDestructors test does the maximum possible number of its 
destructor's iterations, TSan is unable to jump in after the last one.
This leads to false race reports between the TSD destructor and the next user 
of the same TSD slot.

Original issue reported on code.google.com by gli...@google.com on 10 Dec 2012 at 3:37

GoogleCodeExporter commented 9 years ago
I think we just need to reduce number of iterations in the test.
This issue occurs on a single weird test. I don't want to complicate tsan just 
because of that test.

Original comment by dvyu...@google.com on 2 Sep 2014 at 2:28