Open ghost opened 3 years ago
@ruipacheco commented on Feb 21, 2019, 2:31 PM UTC:
Maybe report this in the asio repo? https://github.com/chriskohlhoff/asio
Same issue when using an asio context for sockets and, in a seperate thread, creating a raw socket. I dont really see how to avoid getting this issue, as you can hardly mutex the creation of sockets, and even then, it won't make a difference...?
Wondering if this is actually a data race (could the two sockets somehow cause a data race in pthread/libstdc++?).
Happens with Boost 1.84 RC1. Reported by Boost.MySQL CIs, which have recently added TSAN builds. Tests create and run only async ops on sockets (connect, read and write). If I have the time, I'll try to post a minimal reproducible example.
Stacktrace:
WARNING: ThreadSanitizer: data race (pid=4950)
Read of size 1 at 0x7b280000a0f8 by thread T1:
#0 boost::asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock(boost::asio::detail::conditionally_enabled_mutex&) conditionally_enabled_mutex.hpp:53 (boost_mysql_thread_safety:x86_64+0x100074942)
#1 boost::asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock(boost::asio::detail::conditionally_enabled_mutex&) conditionally_enabled_mutex.hpp:52 (boost_mysql_thread_safety:x86_64+0x1000467f5)
#2 boost::asio::detail::kqueue_reactor::run(long, boost::asio::detail::op_queue<boost::asio::detail::scheduler_operation>&) kqueue_reactor.ipp:487 (boost_mysql_thread_safety:x86_64+0x10004a78c)
#3 non-virtual thunk to boost::asio::detail::kqueue_reactor::run(long, boost::asio::detail::op_queue<boost::asio::detail::scheduler_operation>&) kqueue_reactor.ipp (boost_mysql_thread_safety:x86_64+0x10004b189)
#4 boost::asio::detail::scheduler::do_run_one(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&, boost::asio::detail::scheduler_thread_info&, boost::system::error_code const&) scheduler.ipp:477 (boost_mysql_thread_safety:x86_64+0x100052200)
#5 boost::asio::detail::scheduler::run(boost::system::error_code&) scheduler.ipp:210 (boost_mysql_thread_safety:x86_64+0x10003f715)
#6 boost::asio::thread_pool::thread_function::operator()() thread_pool.ipp:39 (boost_mysql_thread_safety:x86_64+0x10004377a)
#7 boost::asio::detail::posix_thread::func<boost::asio::thread_pool::thread_function>::run() posix_thread.hpp:86 (boost_mysql_thread_safety:x86_64+0x10007b7c9)
#8 boost_asio_detail_posix_thread_function posix_thread.ipp:74 (boost_mysql_thread_safety:x86_64+0x10004d2fe)
Previous write of size 1 at 0x7b280000a0f8 by thread T4 (mutexes: write M106):
#0 boost::asio::detail::conditionally_enabled_mutex::conditionally_enabled_mutex(bool) conditionally_enabled_mutex.hpp:109 (boost_mysql_thread_safety:x86_64+0x10007469e)
#1 boost::asio::detail::conditionally_enabled_mutex::conditionally_enabled_mutex(bool) conditionally_enabled_mutex.hpp:110 (boost_mysql_thread_safety:x86_64+0x100045fba)
#2 boost::asio::detail::kqueue_reactor::descriptor_state::descriptor_state(bool) kqueue_reactor.hpp:69 (boost_mysql_thread_safety:x86_64+0x10007c129)
#3 boost::asio::detail::kqueue_reactor::descriptor_state::descriptor_state(bool) kqueue_reactor.hpp:69 (boost_mysql_thread_safety:x86_64+0x10007c0ba)
#4 boost::asio::detail::kqueue_reactor::descriptor_state* boost::asio::detail::object_pool_access::create<boost::asio::detail::kqueue_reactor::descriptor_state, bool>(bool) object_pool.hpp:41 (boost_mysql_thread_safety:x86_64+0x10007c018)
#5 boost::asio::detail::kqueue_reactor::descriptor_state* boost::asio::detail::object_pool<boost::asio::detail::kqueue_reactor::descriptor_state>::alloc<bool>(bool) object_pool.hpp:114 (boost_mysql_thread_safety:x86_64+0x10004b390)
#6 boost::asio::detail::kqueue_reactor::allocate_descriptor_state() kqueue_reactor.ipp:566 (boost_mysql_thread_safety:x86_64+0x100047ad4)
#7 boost::asio::detail::kqueue_reactor::register_descriptor(int, boost::asio::detail::kqueue_reactor::descriptor_state*&) kqueue_reactor.ipp:145 (boost_mysql_thread_safety:x86_64+0x10004793d)
#8 boost::asio::detail::reactive_socket_service_base::do_open(boost::asio::detail::reactive_socket_service_base::base_implementation_type&, int, int, int, boost::system::error_code&) reactive_socket_service_base.ipp:188 (boost_mysql_thread_safety:x86_64+0x10004ef24)
#9 boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::open(boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::implementation_type&, boost::asio::ip::tcp const&, boost::system::error_code&) reactive_socket_service.hpp:129 (boost_mysql_thread_safety:x86_64+0x100114945)
#10 decltype(async_initiate<boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >, void (boost::system::error_code)>(decltype(__declval<boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> > >(0)) std::__1::declval<boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>::initiate_async_connect>()(), fp0, fp, decltype(__declval<boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> > >(0)) std::__1::declval<boost::system::error_code&>()())) boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>::async_connect<boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> > >(boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const&, boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >&&) basic_socket.hpp:978 (boost_mysql_thread_safety:x86_64+0x10011e789)
#11 void boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >::process<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >(boost::system::error_code, int, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>) connect.hpp:364 (boost_mysql_thread_safety:x86_64+0x10011e1b3)
#12 boost::asio::detail::range_connect_op<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >::operator()(boost::system::error_code, int) connect.hpp:339 (boost_mysql_thread_safety:x86_64+0x10011db98)
#13 void boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor>::operator()<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition>(boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>&&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&, boost::asio::detail::default_connect_condition const&) const connect.hpp:456 (boost_mysql_thread_safety:x86_64+0x10011d9ac)
#14 void boost::asio::detail::completion_handler_async_result<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, void (boost::system::error_code, boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>)>::initiate<boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&, boost::asio::detail::default_connect_condition>(boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor>&&, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>&&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&, boost::asio::detail::default_connect_condition&&) async_result.hpp:273 (boost_mysql_thread_safety:x86_64+0x10011d875)
#15 boost::asio::constraint<detail::async_result_has_initiate_memfn<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, void (boost::system::error_code, boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>)>::value, decltype(async_result<std::__1::decay<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >::type, void (boost::system::error_code, boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>)>::initiate(static_cast<boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor>>(fp), static_cast<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>>(fp0), static_cast<boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&>(fp1), static_cast<boost::asio::detail::default_connect_condition>(fp1)))>::type boost::asio::async_initiate<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, void (boost::system::error_code, boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>), boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&, boost::asio::detail::default_connect_condition>(boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor>&&, boost::asio::type_identity<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >::type&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&, boost::asio::detail::default_connect_condition&&) async_result.hpp:570 (boost_mysql_thread_safety:x86_64+0x10011d7a5)
#16 decltype(async_initiate<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, void (boost::system::error_code, boost::asio::ip::tcp::endpoint)>(declval<boost::asio::detail::initiate_async_range_connect<boost::asio::ip::tcp, boost::asio::any_io_executor> >(), fp1, fp0, decltype(__declval<boost::asio::ip::tcp>(0)) std::__1::declval<boost::asio::detail::default_connect_condition>()())) boost::asio::async_connect<boost::asio::ip::tcp, boost::asio::any_io_executor, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >(boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>&&, boost::asio::constraint<is_endpoint_sequence<boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >::value, int>::type) connect.hpp:703 (boost_mysql_thread_safety:x86_64+0x100117624)
#17 void boost::mysql::detail::variant_stream::connect_op::operator()<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >(boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>&, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>) variant_stream.hpp:329 (boost_mysql_thread_safety:x86_64+0x100116e50)
#18 void boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>::operator()<boost::system::error_code const&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&>(boost::system::error_code const&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&) compose.hpp:92 (boost_mysql_thread_safety:x86_64+0x10011c396)
#19 boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >::operator()() bind_handler.hpp:181 (boost_mysql_thread_safety:x86_64+0x10011c1f6)
#20 void boost::asio::detail::executor_function::complete<boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >, std::__1::allocator<void> >(boost::asio::detail::executor_function::impl_base*, bool) executor_function.hpp:113 (boost_mysql_thread_safety:x86_64+0x10011cff0)
#21 boost::asio::detail::executor_function::operator()() executor_function.hpp:61 (boost_mysql_thread_safety:x86_64+0x10000bb1a)
#22 void boost::asio::thread_pool::basic_executor_type<std::__1::allocator<void>, 8u>::do_execute<boost::asio::detail::executor_function>(boost::asio::detail::executor_function&&, std::__1::integral_constant<bool, false>) const thread_pool.hpp:111 (boost_mysql_thread_safety:x86_64+0x10001cc67)
#23 void boost::asio::thread_pool::basic_executor_type<std::__1::allocator<void>, 8u>::execute<boost::asio::detail::executor_function>(boost::asio::detail::executor_function&&) const thread_pool.hpp:542 (boost_mysql_thread_safety:x86_64+0x10001cb85)
#24 void boost::asio::execution::detail::any_executor_base::execute_ex<boost::asio::thread_pool::basic_executor_type<std::__1::allocator<void>, 8u> >(boost::asio::execution::detail::any_executor_base const&, boost::asio::detail::executor_function&&) any_executor.hpp:900 (boost_mysql_thread_safety:x86_64+0x10001c8cf)
#25 void boost::asio::execution::detail::any_executor_base::execute<boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> > >(boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >&&) const any_executor.hpp:681 (boost_mysql_thread_safety:x86_64+0x10011c5ec)
#26 void boost::asio::detail::handler_work_base<boost::asio::any_completion_executor, boost::asio::any_io_executor, boost::asio::io_context, boost::asio::executor, void>::dispatch<boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)> >(boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >&, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>&) handler_work.hpp:399 (boost_mysql_thread_safety:x86_64+0x10011c261)
#27 void boost::asio::detail::handler_work<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::asio::any_io_executor, void>::complete<boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> > >(boost::asio::detail::binder2<boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::system::error_code, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> >&, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>&) handler_work.hpp:437 (boost_mysql_thread_safety:x86_64+0x10011bdb6)
#28 boost::asio::detail::resolve_query_op<boost::asio::ip::tcp, boost::asio::detail::composed_op<boost::mysql::detail::variant_stream::connect_op, boost::asio::detail::composed_work<void (boost::asio::any_io_executor)>, boost::asio::any_completion_handler<void (boost::system::error_code)>, void (boost::system::error_code)>, boost::asio::any_io_executor>::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) resolve_query_op.hpp:131 (boost_mysql_thread_safety:x86_64+0x10011b852)
#29 boost::asio::detail::scheduler_operation::complete(void*, boost::system::error_code const&, unsigned long) scheduler_operation.hpp:40 (boost_mysql_thread_safety:x86_64+0x100053937)
#30 boost::asio::detail::scheduler::do_run_one(boost::asio::detail::conditionally_enabled_mutex::scoped_lock&, boost::asio::detail::scheduler_thread_info&, boost::system::error_code const&) scheduler.ipp:493 (boost_mysql_thread_safety:x86_64+0x1000522d3)
#31 boost::asio::detail::scheduler::run(boost::system::error_code&) scheduler.ipp:210 (boost_mysql_thread_safety:x86_64+0x10003f715)
#32 boost::asio::thread_pool::thread_function::operator()() thread_pool.ipp:39 (boost_mysql_thread_safety:x86_64+0x10004377a)
#33 boost::asio::detail::posix_thread::func<boost::asio::thread_pool::thread_function>::run() posix_thread.hpp:86 (boost_mysql_thread_safety:x86_64+0x10007b7c9)
#34 boost_asio_detail_posix_thread_function posix_thread.ipp:74 (boost_mysql_thread_safety:x86_64+0x10004d2fe)
@Alkenso commented on Sep 23, 2018, 6:23 PM UTC:
Data race while sync connect to socket when io_service is running on another thread.
I've found strange data race (reported by Xcode Thread Sanitizer) while performing synchronous connect to the socket when io_service is already running in another thread.
It seems like io_service::run tries to read memory of the object which has not been completely constructed.
The issue is reproduces in boost 1.67 and 1.68, but with earlier versions (like versions of 2016 year) all ok.
Report example 1:
Report example 2:
Sample code:
This issue was moved by chriskohlhoff from boostorg/asio#149.