> It seems my original concerns [1] about thread safety are somewhat justified > now, according to helgrind: > > development-branch: 236 errors from 8 contexts > This branch: 1998 errors from 9 contexts > > Tested with: > valgrind --tool=helgrind bin/mir_unit_tests > --gtest_filter="SwitchingBundle*" > > [1] https://code.launchpad.net/~alan-griffiths/mir/refactoring-so- > SwitchingBundle-can-control-completion-of-client_acquire/+merge/204244 > > I can't immediately see what the new context is, but the significant increase > in errors warrants some attention. With the following suppression file we get a clean run. (Please check you're happy with these suppressions.) AFAICS the only possibly contentious one is for client_acquire_blocking() in test_swapping_swappers.cpp ############################################################################### # Part 1: Suppress spurious races in std library functions { std::atomic::load Helgrind:Race fun:_ZNKSt13__atomic_baseIbE4loadESt12memory_order } { std::atomic::store Helgrind:Race fun:_ZNSt13__atomic_baseIbE5storeEbSt12memory_order } { std::mutex::unlock() Helgrind:Race fun:_ZNSt5mutex6unlockEv obj:* } { std::mutex::lock() Helgrind:Race fun:_ZNSt5mutex4lockEv obj:* } { std::thread::join Helgrind:Race obj:/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so fun:_ZNSt6thread4joinEv } { std::unique_lock::~unique_lock() Helgrind:Race fun:_ZNSt11unique_lockISt5mutexED1Ev obj:* } { std::unique_lock::unique_lock(std::mutex&) Helgrind:Race fun:_ZNSt11unique_lockISt5mutexEC1ERS0_ } { std::shared_ptr::get() const Helgrind:Race fun:_ZNKSt12__shared_ptrIN3mir8graphics6BufferELN9__gnu_cxx12_Lock_policyE2EE3getEv obj:* } { std::chrono::duration_cast Helgrind:Race fun:_ZNSt6chrono20__duration_cast_implINS_8durationIlSt5ratioILl1ELl1EEEES2_ILl1ELl1000EElLb1ELb0EE6__castIlS5_EES4_RKNS1_IT_T0_EE } { std::thread::_Impl_base::~_Impl_base() Helgrind:Race fun:_ZNSt6thread10_Impl_baseD1Ev } { std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() Helgrind:Race fun:_ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EED1Ev } ############################################################################### # Part 2: Suppress spurious races in std library template instantiations { std::thread::_Impl, std::reference_wrapper, std::reference_wrapper))(mir::compositor::SwitchingBundle&, unsigned long&, mir::graphics::BufferID&)> >::~_Impl() Helgrind:Race fun:_ZNSt6thread5_ImplISt12_Bind_simpleIFPFvRN3mir10compositor15SwitchingBundleERmRNS2_8graphics8BufferIDEESt17reference_wrapperIS4_ESC_ImESC_IS8_EEEED1Ev } { std::thread::_Impl, int))(mir::compositor::SwitchingBundle&, int)> >::~_Impl() Helgrind:Race fun:_ZNSt6thread5_ImplISt12_Bind_simpleIFPFvRN3mir10compositor15SwitchingBundleEiESt17reference_wrapperIS4_EiEEED1Ev } ############################################################################### # Part 3: Suppress spurious races in Mir test code that I've reviewed carefully { (anonymous namespace)::client_acquire_blocking(mir::compositor::SwitchingBundle&) Helgrind:Race fun:_ZN12_GLOBAL__N_123client_acquire_blockingERN3mir10compositor15SwitchingBundleE }