Skip to content

sporadic data race during framework shutdown #733

@jeffdiclemente

Description

@jeffdiclemente

data race flagged by ThreadSanitizer build:

10: [ RUN      ] BundleTest.TestFrameworkAccessDuringFrameworkShutdown
10: ==================
10: WARNING: ThreadSanitizer: data race (pid=12064)
10:   Read of size 8 at 0x7b6400004b68 by thread T71:
10:     #0 cppmicroservices::CoreBundleContext::GetDataStorage[abi:cxx11](long) const <null> (libCppMicroServices.so.3.7.3+0x17d5a7)
10:     #1 cppmicroservices::BundlePrivate::BundlePrivate(cppmicroservices::CoreBundleContext*, std::shared_ptr<cppmicroservices::BundleArchive> const&) <null> (libCppMicroServices.so.3.7.3+0x156873)
10:     #2 std::__shared_ptr<cppmicroservices::BundlePrivate, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<cppmicroservices::BundlePrivate>, cppmicroservices::CoreBundleContext*&, std::shared_ptr<cppmicroservices::BundleArchive> const&>(std::_Sp_alloc_shared_tag<std::allocator<cppmicroservices::BundlePrivate> >, cppmicroservices::CoreBundleContext*&, std::shared_ptr<cppmicroservices::BundleArchive> const&) <null> (libCppMicroServices.so.3.7.3+0x1661b0)
10:     #3 cppmicroservices::BundleRegistry::Install0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<cppmicroservices::BundleResourceContainer> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, cppmicroservices::AnyMap const&) <null> (libCppMicroServices.so.3.7.3+0x15f51f)
10:     #4 cppmicroservices::BundleRegistry::Install(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cppmicroservices::BundlePrivate*, cppmicroservices::AnyMap const&) <null> (libCppMicroServices.so.3.7.3+0x15e4ab)
10:     #5 cppmicroservices::BundleContext::InstallBundles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cppmicroservices::AnyMap const&) <null> (libCppMicroServices.so.3.7.3+0x12a4ad)
10:     #6 cppmicroservices::testing::InstallLib(cppmicroservices::BundleContext, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cppmicroservices::AnyMap const&) <null> (usFrameworkTests+0x858742)
10:     #7 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<BundleTest_TestFrameworkAccessDuringFrameworkShutdown_Test::TestBody()::$_3> >, void> >::_M_invoke(std::_Any_data const&) <null> (usFrameworkTests+0x83600b)
10:     #8 std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) <null> (usFrameworkTests+0x6aa27b)
10:     #9 void std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::'lambda0'()::__invoke() <null> (usFrameworkTests+0x6aa3d6)
10:     #10 pthread_once <null> (usFrameworkTests+0x4dbc79)
10:     #11 std::thread::_State_impl<std::thread::_Invoker<std::tuple<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<BundleTest_TestFrameworkAccessDuringFrameworkShutdown_Test::TestBody()::$_3> >, void>::_Async_state_impl(std::thread::_Invoker<std::tuple<BundleTest_TestFrameworkAccessDuringFrameworkShutdown_Test::TestBody()::$_3> >&&)::'lambda'()> > >::_M_run() <null> (usFrameworkTests+0x835bbb)
10:     #12 <null> <null> (libstdc++.so.6+0xd44bf)
10: 
10:   Previous write of size 8 at 0x7b6400004b68 by thread T74 (mutexes: write M1134479774031283720):
10:     #0 cppmicroservices::CoreBundleContext::Uninit1() <null> (libCppMicroServices.so.3.7.3+0x17d4fe)
10:     #1 cppmicroservices::FrameworkPrivate::Shutdown0(bool, bool) <null> (libCppMicroServices.so.3.7.3+0xb34aa)
10:     #2 std::thread::_State_impl<std::thread::_Invoker<std::tuple<std::_Bind<void (cppmicroservices::FrameworkPrivate::* (cppmicroservices::FrameworkPrivate*, bool, bool))(bool, bool)> > > >::_M_run() <null> (libCppMicroServices.so.3.7.3+0xb72bf)
10:     #3 <null> <null> (libstdc++.so.6+0xd44bf)
10: 
10:   Location is heap block of size 1280 at 0x7b6400004b00 allocated by main thread:
10:     #0 operator new(unsigned long) <null> (usFrameworkTests+0x56749b)
10:     #1 cppmicroservices::FrameworkFactory::NewFramework(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, cppmicroservices::Any, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, cppmicroservices::Any> > > const&, std::ostream*) <null> (libCppMicroServices.so.3.7.3+0xaffd8)
10:     #2 cppmicroservices::FrameworkFactory::NewFramework() <null> (libCppMicroServices.so.3.7.3+0xb03b6)
10:     #3 testing::internal::TestFactoryImpl<BundleTest_TestFrameworkAccessDuringFrameworkShutdown_Test>::CreateTest() <null> (usFrameworkTests+0x844da9)
10:     #4 testing::Test* testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::TestFactoryBase, testing::Test*>(testing::internal::TestFactoryBase*, testing::Test* (testing::internal::TestFactoryBase::*)(), char const*) <null> (libgtest.so.1.11.0+0x585d3)
10:     #5 __libc_start_main <null> (libc.so.6+0x21c86)
10: 
10:   Mutex M1134479774031283720 is already destroyed.
10: 
10:   Thread T71 (tid=14401, running) created by main thread at:
10:     #0 pthread_create <null> (usFrameworkTests+0x4d89bb)
10:     #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd4765)
10:     #2 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) <null> (libgtest.so.1.11.0+0x58273)
10:     #3 __libc_start_main <null> (libc.so.6+0x21c86)
10: 
10:   Thread T74 (tid=14402, running) created by main thread at:
10:     #0 pthread_create <null> (usFrameworkTests+0x4d89bb)
10:     #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd4765)
10:     #2 cppmicroservices::FrameworkPrivate::Stop(unsigned int) <null> (libCppMicroServices.so.3.7.3+0xb4ae9)
10:     #3 cppmicroservices::Bundle::Stop() <null> (libCppMicroServices.so.3.7.3+0x1204b2)
10:     #4 BundleTest_TestFrameworkAccessDuringFrameworkShutdown_Test::TestBody() <null> (usFrameworkTests+0x834758)
10:     #5 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) <null> (libgtest.so.1.11.0+0x58273)
10:     #6 __libc_start_main <null> (libc.so.6+0x21c86)
10: 
10: SUMMARY: ThreadSanitizer: data race (/home/runner/work/CppMicroServices/CppMicroServices/build/lib/libCppMicroServices.so.3.7.3+0x17d5a7) in cppmicroservices::CoreBundleContext::GetDataStorage[abi:cxx11](long) const
10: ==================

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions