helgrind: Possible data race - inconsistent locking in PendingCallCache
==21606== ----------------------------------------------------------------
==21606==
==21606== Lock at 0x9258BA8 was first observed
==21606== at 0x4C2FC35: pthread_mutex_lock (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==21606== by 0x4F9EB21: __gthread_mutex_lock(pthread_mutex_t*) (gthr-default.h:748)
==21606== by 0x4F9F171: std::mutex::lock() (mutex:134)
==21606== by 0x4FAFE86: std::unique_lock<std::mutex>::lock() (mutex:511)
==21606== by 0x4FAFC30: std::unique_lock<std::mutex>::unique_lock(std::mutex&) (mutex:443)
==21606== by 0x4FE7B0D: mir::client::rpc::detail::PendingCallCache::save_completion_details(mir::protobuf::wire::Invocation&, google::protobuf::Message*, std::shared_ptr<google::protobuf::Closure> const&) (mir_basic_rpc_channel.cpp:41)
==21606== by 0x4FD12E1: mir::client::rpc::MirSocketRpcChannel::CallMethod(google::protobuf::MethodDescriptor const*, google::protobuf::RpcController*, google::protobuf::Message const*, google::protobuf::Message*, google::protobuf::Closure*) (mir_socket_rpc_channel.cpp:274)
==21606== by 0x61BBFFE: mir::protobuf::DisplayServer_Stub::connect(google::protobuf::RpcController*, mir::protobuf::ConnectParameters const*, mir::protobuf::Connection*, google::protobuf::Closure*) (mir_protobuf.pb.cc:7419)
==21606== by 0x4FAA976: MirConnection::connect(char const*, void (*)(MirConnection*, void*), void*) (mir_connection.cpp:260)
==21606== by 0x4FA6343: mir_default_connect(char const*, char const*, void (*)(MirConnection*, void*), void*) (mir_client_library.cpp:98)
==21606== by 0x4FA6603: mir_connect (mir_client_library.cpp:142)
==21606== by 0x4FA66B1: mir_connect_sync (mir_client_library.cpp:168)
==21606==
==21606== Lock at 0x9267668 was first observed
==21606== at 0x4C2FC35: pthread_mutex_lock (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==21606== by 0x4FA9205: __gthread_mutex_lock(pthread_mutex_t*) (gthr-default.h:748)
==21606== by 0x4FA9255: __gthread_recursive_mutex_lock(pthread_mutex_t*) (gthr-default.h:810)
==21606== by 0x4FAB8BB: std::recursive_mutex::lock() (mutex:175)
==21606== by 0x4FAC37D: std::lock_guard<std::recursive_mutex>::lock_guard(std::recursive_mutex&) (mutex:414)
==21606== by 0x4FB1197: MirSurface::created(void (*)(MirSurface*, void*), void*) (mir_surface.cpp:197)
==21606== by 0x4FB5734: google::protobuf::internal::MethodClosure2<MirSurface, void (*)(MirSurface*, void*), void*>::Run() (common.h:969)
==21606== by 0x4FD0EBD: mir::client::rpc::MirSocketRpcChannel::receive_file_descriptors(google::protobuf::Message*, google::protobuf::Closure*) (mir_socket_rpc_channel.cpp:211)
==21606== by 0x4FE7136: google::protobuf::internal::MethodClosure2<mir::client::rpc::MirSocketRpcChannel, google::protobuf::Message*, google::protobuf::Closure*>::Run() (common.h:969)
==21606== by 0x4FE7D08: mir::client::rpc::detail::PendingCallCache::complete_response(mir::protobuf::wire::Result&) (mir_basic_rpc_channel.cpp:69)
==21606== by 0x4FD195B: mir::client::rpc::MirSocketRpcChannel::read_message() (mir_socket_rpc_channel.cpp:372)
==21606== by 0x4FD1745: mir::client::rpc::MirSocketRpcChannel::on_header_read(boost::system::error_code const&) (mir_socket_rpc_channel.cpp:335)
==21606==
==21606== Lock at 0x92AA0D8 was first observed
==21606== at 0x4C2F8EA: pthread_mutex_init (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==21606== by 0x5272FC9: ??? (in /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so.1.0.0)
==21606== by 0x402984: mir_eglapp_init (eglapp.c:352)
==21606== by 0x401C29: main (egltriangle.c:85)
==21606==
==21606== Possible data race during read of size 8 at 0xF62F220 by thread #2
==21606== Locks held: 1, at address 0x9258BA8
==21606== at 0x4FDA553: std::vector<char, std::allocator<char> >::~vector() (stl_vector.h:416)
==21606== by 0x4FE36A5: mir::client::rpc::detail::PendingCallCache::PendingCall::~PendingCall() (mir_basic_rpc_channel.h:71)
==21606== by 0x4FE36C3: std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall>::~pair() (stl_pair.h:96)
==21606== by 0x4FE36E1: std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >::~_Rb_tree_node() (stl_tree.h:131)
==21606== by 0x4FE36FF: void __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::destroy<std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >(std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >*) (new_allocator.h:124)
==21606== by 0x4FE19E6: std::_Rb_tree<int, std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall>, std::_Select1st<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >, std::less<int>, std::allocator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >*) (stl_tree.h:421)
==21606== by 0x4FE982B: std::_Rb_tree<int, std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall>, std::_Select1st<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >, std::less<int>, std::allocator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::_M_erase_aux(std::_Rb_tree_const_iterator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >) (stl_tree.h:1746)
==21606== by 0x4FE8EC5: _ZNSt8_Rb_treeIiSt4pairIKiN3mir6client3rpc6detail16PendingCallCache11PendingCallEESt10_Select1stIS8_ESt4lessIiESaIS8_EE5eraseB5cxx11ESt17_Rb_tree_iteratorIS8_E (stl_tree.h:820)
==21606== by 0x4FE883E: _ZNSt3mapIiN3mir6client3rpc6detail16PendingCallCache11PendingCallESt4lessIiESaISt4pairIKiS5_EEE5eraseB5cxx11ESt17_Rb_tree_iteratorISA_E (stl_map.h:697)
==21606== by 0x4FE7CE1: mir::client::rpc::detail::PendingCallCache::complete_response(mir::protobuf::wire::Result&) (mir_basic_rpc_channel.cpp:66)
==21606== by 0x4FD195B: mir::client::rpc::MirSocketRpcChannel::read_message() (mir_socket_rpc_channel.cpp:372)
==21606== by 0x4FD1745: mir::client::rpc::MirSocketRpcChannel::on_header_read(boost::system::error_code const&) (mir_socket_rpc_channel.cpp:335)
==21606==
==21606== This conflicts with a previous write of size 8 by thread #1
==21606== Locks held: 2, at addresses 0x9267668 0x92AA0D8
==21606== at 0x4FDFF5B: std::vector<char, std::allocator<char> >::_M_default_append(unsigned long) (vector.tcc:574)
==21606== by 0x4FDCF5A: std::vector<char, std::allocator<char> >::resize(unsigned long) (stl_vector.h:667)
==21606== by 0x4FD1402: mir::client::rpc::MirSocketRpcChannel::send_message(mir::protobuf::wire::Invocation const&, std::vector<char, std::allocator<char> >&, mir::protobuf::wire::Invocation const&) (mir_socket_rpc_channel.cpp:292)
==21606== by 0x4FD12FD: mir::client::rpc::MirSocketRpcChannel::CallMethod(google::protobuf::MethodDescriptor const*, google::protobuf::RpcController*, google::protobuf::Message const*, google::protobuf::Message*, google::protobuf::Closure*) (mir_socket_rpc_channel.cpp:277)
==21606== by 0x61BC148: mir::protobuf::DisplayServer_Stub::next_buffer(google::protobuf::RpcController*, mir::protobuf::SurfaceId const*, mir::protobuf::Buffer*, google::protobuf::Closure*) (mir_protobuf.pb.cc:7440)
==21606== by 0x4FB0F69: MirSurface::next_buffer(void (*)(MirSurface*, void*), void*) (mir_surface.cpp:151)
==21606== by 0x4FA0F3D: mir::client::gbm::GBMNativeSurface::advance_buffer(MirBufferPackage*) (gbm_native_surface.cpp:63)
==21606== by 0x4FA0E43: (anonymous namespace)::advance_buffer_static(MirMesaEGLNativeSurface*, MirBufferPackage*) (gbm_native_surface.cpp:31)
==21606==
==21606== Address 0xF62F220 is 48 bytes inside a block of size 88 alloc'd
==21606== at 0x4C2A8F9: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==21606== by 0x4FE9F77: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::allocate(unsigned long, void const*) (new_allocator.h:104)
==21606== by 0x4FE9A21: std::_Rb_tree<int, std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall>, std::_Select1st<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >, std::less<int>, std::allocator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::_M_get_node() (stl_tree.h:370)
==21606== by 0x4FE9092: std::_Rb_tree_node<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >* std::_Rb_tree<int, std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall>, std::_Select1st<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >, std::less<int>, std::allocator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::_M_create_node<std::piecewise_construct_t const&, std::tuple<int&&>, std::tuple<> >(std::piecewise_construct_t const&, std::tuple<int&&>&&, std::tuple<>&&) (stl_tree.h:403)
==21606== by 0x4FE8BDB: std::_Rb_tree_iterator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > std::_Rb_tree<int, std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall>, std::_Select1st<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >, std::less<int>, std::allocator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<int&&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> >, std::piecewise_construct_t const&, std::tuple<int&&>&&, std::tuple<>&&) (stl_tree.h:1669)
==21606== by 0x4FE86D0: std::map<int, mir::client::rpc::detail::PendingCallCache::PendingCall, std::less<int>, std::allocator<std::pair<int const, mir::client::rpc::detail::PendingCallCache::PendingCall> > >::operator[](int&&) (stl_map.h:484)
==21606== by 0x4FE7B4A: mir::client::rpc::detail::PendingCallCache::save_completion_details(mir::protobuf::wire::Invocation&, google::protobuf::Message*, std::shared_ptr<google::protobuf::Closure> const&) (mir_basic_rpc_channel.cpp:43)
==21606== by 0x4FD12E1: mir::client::rpc::MirSocketRpcChannel::CallMethod(google::protobuf::MethodDescriptor const*, google::protobuf::RpcController*, google::protobuf::Message const*, google::protobuf::Message*, google::protobuf::Closure*) (mir_socket_rpc_channel.cpp:274)
==21606== by 0x61BC148: mir::protobuf::DisplayServer_Stub::next_buffer(google::protobuf::RpcController*, mir::protobuf::SurfaceId const*, mir::protobuf::Buffer*, google::protobuf::Closure*) (mir_protobuf.pb.cc:7440)
==21606== by 0x4FB0F69: MirSurface::next_buffer(void (*)(MirSurface*, void*), void*) (mir_surface.cpp:151)
==21606== by 0x4FA0F3D: mir::client::gbm::GBMNativeSurface::advance_buffer(MirBufferPackage*) (gbm_native_surface.cpp:63)
==21606== by 0x4FA0E43: (anonymous namespace)::advance_buffer_static(MirMesaEGLNativeSurface*, MirBufferPackage*) (gbm_native_surface.cpp:31)
==21606==
==21606== ----------------------------------------------------------------
Fix committed into lp:mir/devel at revision 1316, scheduled for release in mir, milestone Unknown