Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data race introduced by PageEvictorTest.pageEvictBasic #118

Open
zz-jason opened this issue Aug 21, 2024 · 0 comments
Open

Data race introduced by PageEvictorTest.pageEvictBasic #118

zz-jason opened this issue Aug 21, 2024 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@zz-jason
Copy link
Owner

Bug Report

Minimal reproduction step

cmake --preset debug_tsan
cmake --build build/debug_tsan/ -j `nproc`
TSAN_OPTIONS="suppressions=$(pwd)/tests/tsan.supp" ctest --test-dir build/debug_tsan --output-on-failure -j 2 > build/build.out 2>&1

Git hash: d5e3d71

Expected result

test pass

Actual result

the race report:

[ RUN      ] PageEvictorTest.pageEvictBasic
Clean store dir: /tmp/PageEvictorTest_pageEvictBasic
/root/code/leanstore/tests/buffer-manager/PageEvictorTest.cpp:44: Failure
Value of: pageEvictor->mPartitions[0]->NeedMoreFreeBfs()
  Actual: true
Expected: false

==================
WARNING: ThreadSanitizer: data race (pid=98759)
  Read of size 8 at 0x727400000088 by main thread:
    #0 std::vector<leanstore::storage::BufferFrame*, std::allocator<leanstore::storage::BufferFrame*> >::_M_erase_at_end(leanstore::storage::BufferFrame**) /usr/include/c++/13/bits/stl_vector.h:1935 (libleanstore.so+0xa9b9a9) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #1 std::vector<leanstore::storage::BufferFrame*, std::allocator<leanstore::storage::BufferFrame*> >::clear() /usr/include/c++/13/bits/stl_vector.h:1606 (libleanstore.so+0xa9a65c) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #2 leanstore::storage::PageEvictor::randomBufferFramesToCoolOrEvict() /root/code/leanstore/src/buffer-manager/PageEvictor.cpp:213 (libleanstore.so+0xa93e76) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #3 leanstore::storage::PageEvictor::PickBufferFramesToCool(leanstore::storage::Partition&) /root/code/leanstore/src/buffer-manager/PageEvictor.cpp:58 (libleanstore.so+0xa92775) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #4 leanstore::storage::test::PageEvictorTest_pageEvictBasic_Test::TestBody() /root/code/leanstore/tests/buffer-manager/PageEvictorTest.cpp:45 (PageEvictorTest+0x834f5) (BuildId: 5acd561ac1cabda44a032715def151ce4de4d4c1)
    #5 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /root/opt/vcpkg/buildtrees/gtest/src/v1.14.0-bcf93537a8.clean/googletest/src/gtest.cc:2612 (PageEvictorTest+0xd4702) (BuildId: 5acd561ac1cabda44a032715def151ce4de4d4c1)

  Previous write of size 8 at 0x727400000088 by thread T8:
    #0 std::vector<leanstore::storage::BufferFrame*, std::allocator<leanstore::storage::BufferFrame*> >::push_back(leanstore::storage::BufferFrame* const&) /usr/include/c++/13/bits/stl_vector.h:1288 (libleanstore.so+0xa9a411) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #1 leanstore::storage::PageEvictor::randomBufferFramesToCoolOrEvict() /root/code/leanstore/src/buffer-manager/PageEvictor.cpp:217 (libleanstore.so+0xa93f20) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #2 leanstore::storage::PageEvictor::PickBufferFramesToCool(leanstore::storage::Partition&) /root/code/leanstore/src/buffer-manager/PageEvictor.cpp:58 (libleanstore.so+0xa92775) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #3 leanstore::storage::PageEvictor::runImpl() /root/code/leanstore/src/buffer-manager/PageEvictor.cpp:26 (libleanstore.so+0xa920e6) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #4 leanstore::utils::UserThread::run() <null> (libleanstore.so+0x8a0eab) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #5 void std::__invoke_impl<void, void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*>(std::__invoke_memfun_deref, void (leanstore::utils::UserThread::*&&)(), leanstore::utils::UserThread*&&) <null> (libleanstore.so+0x9f5110) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #6 std::__invoke_result<void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*>::type std::__invoke<void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*>(void (leanstore::utils::UserThread::*&&)(), leanstore::utils::UserThread*&&) /usr/include/c++/13/bits/invoke.h:96 (libleanstore.so+0x9f21f0) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #7 void std::thread::_Invoker<std::tuple<void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) /usr/include/c++/13/bits/std_thread.h:292 (libleanstore.so+0x9e646f) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #8 std::thread::_Invoker<std::tuple<void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*> >::operator()() /usr/include/c++/13/bits/std_thread.h:299 (libleanstore.so+0x9e4e3b) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #9 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*> > >::_M_run() /usr/include/c++/13/bits/std_thread.h:244 (libleanstore.so+0x9e2049) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #10 <null> <null> (libstdc++.so.6+0xeabb3) (BuildId: 40b9b0d17fdeebfb57331304da2b7f85e1396ef2)

  Location is heap block of size 2560 at 0x727400000000 allocated by main thread:
    #0 operator new(unsigned long, std::align_val_t) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:88 (libtsan.so.2+0xa48bf) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 std::__detail::_MakeUniq<leanstore::storage::PageEvictor>::__single_object std::make_unique<leanstore::storage::PageEvictor, leanstore::LeanStore*&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long&, unsigned long&, unsigned char*&, unsigned long&, unsigned long&, std::vector<std::unique_ptr<leanstore::storage::Partition, std::default_delete<leanstore::storage::Partition> >, std::allocator<std::unique_ptr<leanstore::storage::Partition, std::default_delete<leanstore::storage::Partition> > > >&>(leanstore::LeanStore*&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long&, unsigned long&, unsigned char*&, unsigned long&, unsigned long&, std::vector<std::unique_ptr<leanstore::storage::Partition, std::default_delete<leanstore::storage::Partition> >, std::allocator<std::unique_ptr<leanstore::storage::Partition, std::default_delete<leanstore::storage::Partition> > > >&) /usr/include/c++/13/bits/unique_ptr.h:1070 (libleanstore.so+0xa85e09) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #2 leanstore::storage::BufferManager::StartPageEvictors() /root/code/leanstore/src/buffer-manager/BufferManager.cpp:97 (libleanstore.so+0xa769c0) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #3 leanstore::LeanStore::LeanStore(StoreOption*) /root/code/leanstore/src/LeanStore.cpp:78 (libleanstore.so+0x88ed4c) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #4 std::__detail::_MakeUniq<leanstore::LeanStore>::__single_object std::make_unique<leanstore::LeanStore, StoreOption*&>(StoreOption*&) <null> (libleanstore.so+0x8faa0b) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #5 leanstore::LeanStore::Open(StoreOption*) /root/code/leanstore/src/LeanStore.cpp:56 (libleanstore.so+0x88e783) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #6 leanstore::storage::test::PageEvictorTest::SetUp() /root/code/leanstore/tests/buffer-manager/PageEvictorTest.cpp:33 (PageEvictorTest+0x85ee8) (BuildId: 5acd561ac1cabda44a032715def151ce4de4d4c1)
    #7 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /root/opt/vcpkg/buildtrees/gtest/src/v1.14.0-bcf93537a8.clean/googletest/src/gtest.cc:2612 (PageEvictorTest+0xd4702) (BuildId: 5acd561ac1cabda44a032715def151ce4de4d4c1)

  Thread T8 'PageEvictor' (tid=98775, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5a267) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xeac88) (BuildId: 40b9b0d17fdeebfb57331304da2b7f85e1396ef2)
    #2 std::__detail::_MakeUniq<std::thread>::__single_object std::make_unique<std::thread, void (leanstore::utils::UserThread::*)(), leanstore::utils::UserThread*>(void (leanstore::utils::UserThread::*&&)(), leanstore::utils::UserThread*&&) /usr/include/c++/13/bits/unique_ptr.h:1070 (libleanstore.so+0x8df30c) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #3 leanstore::utils::UserThread::Start() /root/code/leanstore/include/leanstore/utils/UserThread.hpp:58 (libleanstore.so+0x8a08ba) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #4 leanstore::storage::BufferManager::StartPageEvictors() /root/code/leanstore/src/buffer-manager/BufferManager.cpp:103 (libleanstore.so+0xa76a72) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #5 leanstore::LeanStore::LeanStore(StoreOption*) /root/code/leanstore/src/LeanStore.cpp:78 (libleanstore.so+0x88ed4c) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #6 std::__detail::_MakeUniq<leanstore::LeanStore>::__single_object std::make_unique<leanstore::LeanStore, StoreOption*&>(StoreOption*&) <null> (libleanstore.so+0x8faa0b) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #7 leanstore::LeanStore::Open(StoreOption*) /root/code/leanstore/src/LeanStore.cpp:56 (libleanstore.so+0x88e783) (BuildId: f5d24e89422743c4692cbb5fd67fa2135f074381)
    #8 leanstore::storage::test::PageEvictorTest::SetUp() /root/code/leanstore/tests/buffer-manager/PageEvictorTest.cpp:33 (PageEvictorTest+0x85ee8) (BuildId: 5acd561ac1cabda44a032715def151ce4de4d4c1)
    #9 void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /root/opt/vcpkg/buildtrees/gtest/src/v1.14.0-bcf93537a8.clean/googletest/src/gtest.cc:2612 (PageEvictorTest+0xd4702) (BuildId: 5acd561ac1cabda44a032715def151ce4de4d4c1)

SUMMARY: ThreadSanitizer: data race /usr/include/c++/13/bits/stl_vector.h:1935 in std::vector<leanstore::storage::BufferFrame*, std::allocator<leanstore::storage::BufferFrame*> >::_M_erase_at_end(leanstore::storage::BufferFrame**)
==================

There are lots of data race errors shown in the race report, which may all share the same root cause with the above one

@zz-jason zz-jason added help wanted Extra attention is needed good first issue Good for newcomers labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant