Mir

helgrind: Possible data race - MirConnection::mutex not used consistently

Bug #1243575 reported by Daniel van Vugt on 2013-10-23
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mir
Fix Released
Medium
Alan Griffiths
mir (Ubuntu)
Medium
Unassigned

Bug Description

helgrind: Possible data race - MirConnection::mutex not used consistently

==21606== ----------------------------------------------------------------
==21606==
==21606== Lock at 0x9258338 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 0x4FAA8E9: MirConnection::connect(char const*, void (*)(MirConnection*, void*), void*) (mir_connection.cpp:251)
==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== by 0x4025D1: mir_eglapp_init (eglapp.c:285)
==21606== by 0x401C29: main (egltriangle.c:85)
==21606==
==21606== Possible data race during read of size 1 at 0x9258C34 by thread #1
==21606== Locks held: 1, at address 0x9258338
==21606== at 0x4FE4E0F: unsigned long boost::asio::detail::reactive_socket_service_base::send<boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boost::asio::mutable_buffers_1> >(boost::asio::detail::reactive_socket_service_base::base_implementation_type&, boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boost::asio::mutable_buffers_1> const&, int, boost::system::error_code&) (reactive_socket_service_base.hpp:183)
==21606== by 0x4FE3F6C: unsigned long boost::asio::stream_socket_service<boost::asio::local::stream_protocol>::send<boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boost::asio::mutable_buffers_1> >(boost::asio::detail::reactive_socket_service<boost::asio::local::stream_protocol>::implementation_type&, boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boost::asio::mutable_buffers_1> const&, int, boost::system::error_code&) (stream_socket_service.hpp:288)
==21606== by 0x4FE276E: unsigned long boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >::write_some<boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boost::asio::mutable_buffers_1> >(boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boost::asio::mutable_buffers_1> const&, boost::system::error_code&) (basic_stream_socket.hpp:630)
==21606== by 0x4FE01A8: unsigned long boost::asio::write<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_all_t>(boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >&, boost::asio::mutable_buffers_1 const&, boost::asio::detail::transfer_all_t, boost::system::error_code&) (write.hpp:48)
==21606== by 0x4FDD0AB: unsigned long boost::asio::write<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1>(boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >&, boost::asio::mutable_buffers_1 const&, boost::system::error_code&) (write.hpp:70)
==21606== by 0x4FD149C: 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:301)
==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 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== This conflicts with a previous write of size 1 by thread #2
==21606== Locks held: none
==21606== at 0x4FD7E74: boost::asio::detail::socket_ops::set_internal_non_blocking(int, unsigned char&, bool, boost::system::error_code&) (socket_ops.ipp:424)
==21606== by 0x4FD93B2: boost::asio::detail::reactive_socket_service_base::start_op(boost::asio::detail::reactive_socket_service_base::base_implementation_type&, int, boost::asio::detail::reactor_op*, bool, bool) (reactive_socket_service_base.ipp:209)
==21606== by 0x4FE4AB3: void boost::asio::detail::reactive_socket_service_base::async_receive<boost::asio::mutable_buffers_1, boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > > >(boost::asio::detail::reactive_socket_service_base::base_implementation_type&, boost::asio::mutable_buffers_1 const&, int, boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > >) (reactive_socket_service_base.hpp:277)
==21606== by 0x4FE396D: void boost::asio::stream_socket_service<boost::asio::local::stream_protocol>::async_receive<boost::asio::mutable_buffers_1, boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > > >(boost::asio::detail::reactive_socket_service<boost::asio::local::stream_protocol>::implementation_type&, boost::asio::mutable_buffers_1 const&, int, boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > >&&) (stream_socket_service.hpp:318)
==21606== by 0x4FE1EBC: void boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >::async_read_some<boost::asio::mutable_buffers_1, boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > > >(boost::asio::mutable_buffers_1 const&, boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > >&&) (basic_stream_socket.hpp:787)
==21606== by 0x4FDF719: boost::asio::detail::read_op<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > >::operator()(boost::system::error_code const&, unsigned long, int) (read.hpp:263)
==21606== by 0x4FDCAD4: void boost::asio::async_read<boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> > >(boost::asio::basic_stream_socket<boost::asio::local::stream_protocol, boost::asio::stream_socket_service<boost::asio::local::stream_protocol> >&, boost::asio::mutable_buffers_1 const&, boost::asio::detail::transfer_exactly_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, mir::client::rpc::MirSocketRpcChannel, boost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<mir::client::rpc::MirSocketRpcChannel*>, boost::arg<1> (*)()> >&&) (read.hpp:511)
==21606== by 0x4FD0681: mir::client::rpc::MirSocketRpcChannel::init()::{lambda()#1}::operator()() const (mir_socket_rpc_channel.cpp:117)
==21606==
==21606== Address 0x9258C34 is 196 bytes inside a block of size 352 alloc'd
==21606== at 0x4C2A8F9: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==21606== by 0x4FCEECD: __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<mir::client::rpc::MirSocketRpcChannel, std::allocator<mir::client::rpc::MirSocketRpcChannel>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (new_allocator.h:104)
==21606== by 0x4FCECD7: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<mir::client::rpc::MirSocketRpcChannel, std::allocator<mir::client::rpc::MirSocketRpcChannel>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<mir::client::rpc::MirSocketRpcChannel, std::allocator<mir::client::rpc::MirSocketRpcChannel>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (alloc_traits.h:351)
==21606== by 0x4FCEB85: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<mir::client::rpc::MirSocketRpcChannel, std::allocator<mir::client::rpc::MirSocketRpcChannel>, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&>(std::_Sp_make_shared_tag, mir::client::rpc::MirSocketRpcChannel*, std::allocator<mir::client::rpc::MirSocketRpcChannel> const&, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&) (shared_ptr_base.h:519)
==21606== by 0x4FCE968: std::__shared_ptr<mir::client::rpc::MirSocketRpcChannel, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<mir::client::rpc::MirSocketRpcChannel>, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&>(std::_Sp_make_shared_tag, std::allocator<mir::client::rpc::MirSocketRpcChannel> const&, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&) (shared_ptr_base.h:986)
==21606== by 0x4FCE79B: std::shared_ptr<mir::client::rpc::MirSocketRpcChannel>::shared_ptr<std::allocator<mir::client::rpc::MirSocketRpcChannel>, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&>(std::_Sp_make_shared_tag, std::allocator<mir::client::rpc::MirSocketRpcChannel> const&, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&) (shared_ptr.h:316)
==21606== by 0x4FCE62E: std::shared_ptr<mir::client::rpc::MirSocketRpcChannel> std::allocate_shared<mir::client::rpc::MirSocketRpcChannel, std::allocator<mir::client::rpc::MirSocketRpcChannel>, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&>(std::allocator<mir::client::rpc::MirSocketRpcChannel> const&, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&) (shared_ptr.h:598)
==21606== by 0x4FCE3BD: std::shared_ptr<mir::client::rpc::MirSocketRpcChannel> std::make_shared<mir::client::rpc::MirSocketRpcChannel, std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&>(std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&) (shared_ptr.h:614)
==21606== by 0x4FCD5E4: mir::client::rpc::make_rpc_channel(std::string const&, std::shared_ptr<mir::client::SurfaceMap> const&, std::shared_ptr<mir::client::DisplayConfiguration> const&, std::shared_ptr<mir::client::rpc::RpcReport> const&, std::shared_ptr<mir::client::LifecycleControl> const&) (make_socket_rpc_channel.cpp:55)
==21606== by 0x4FB7F22: mir::client::DefaultConnectionConfiguration::the_rpc_channel()::{lambda()#1}::operator()() const (default_connection_configuration.cpp:64)
==21606== by 0x4FB8D42: std::_Function_handler<std::shared_ptr<mir::client::rpc::MirBasicRpcChannel> (), mir::client::DefaultConnectionConfiguration::the_rpc_channel()::{lambda()#1}>::_M_invoke(std::_Any_data const&) (functional:2057)
==21606== by 0x4FBB308: std::function<std::shared_ptr<mir::client::rpc::MirBasicRpcChannel> ()>::operator()() const (functional:2464)
==21606==
==21606== ----------------------------------------------------------------

Related branches

tags: added: helgrind
Changed in mir:
assignee: nobody → Alan Griffiths (alan-griffiths)
importance: Undecided → Medium
status: New → In Progress
milestone: none → 0.1.4
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:mir/devel at revision 1316, scheduled for release in mir, milestone Unknown

Changed in mir:
status: In Progress → Fix Committed
Changed in mir:
status: Fix Committed → Fix Released
Daniel van Vugt (vanvugt) wrote :

mir (0.1.4+14.04.20140204-0ubuntu1) trusty; urgency=medium

Changed in mir (Ubuntu):
importance: Undecided → Medium
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers