-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Description
AddressSanitizer detects a heap-use-after-free error during broker shutdown. The issue involves incorrect destruction order between io_context and endpoint objects that hold timer references.
Environment
- Compiler: GCC 12, C++17
- Boost: 1.82.0
- Build flags:
-fsanitize=address,undefined - async_mqtt Version: 6a6d2d5
I simulated SSL/TLS initialization failures to test how the broker handles certificate loading errors, invalid keys, and other SSL-related failure scenarios.
How I Found This
During these tests, while the broker correctly handles the SSL errors themselves, AddressSanitizer consistently reported a heap-use-after-free error during the subsequent shutdown sequence.
This bug occurs during the shutdown/cleanup phase after an SSL initialization failure, not during normal operation. The broker runs fine under normal conditions, but the memory safety issue is exposed when error paths are exercised.
Reproduction
Build with AddressSanitizer and trigger any scenario where SSL/TLS initialization fails.
# Build with AddressSanitizer
cmake -DCMAKE_CXX_FLAGS="-g -fsanitize=address,undefined -fno-omit-frame-pointer" ..
make broker
# Run broker (with fault-injected OpenSSL library to simulate SSL failures)
ASAN_OPTIONS=detect_leaks=0 ./build/tool/broker --cfg broker.conf
Potential Root Cause
At broker.cpp:804, when run_broker() exits:
std::vector<std::shared_ptr<io_context>>destructs first- This destroys the internal
deadline_timer_service endpointobjects (created atbroker.cpp:304) destruct after- Endpoint destructors try to access the already-freed
deadline_timer_service
The problem:endpointobjects hold timers that depend onio_context, but the destruction order is reversed.
Stack Trace
=================================================================
==1188484==ERROR: AddressSanitizer: heap-use-after-free on address 0x7bf2edee0ea0 at pc 0x00000062125c bp 0x7fff32c69990 sp 0x7fff32c69988
READ of size 8 at 0x7bf2edee0ea0 thread T0
#0 0x00000062125b in boost::asio::detail::io_object_impl<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >, boost::asio::any_io_executor>::~io_object_impl() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/io_object_impl.hpp:97
#1 0x00000058de23 in boost::asio::basic_waitable_timer<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock>, boost::asio::any_io_executor>::~basic_waitable_timer() async_mqtt/boost_1_82_0/install/include/boost/asio/basic_waitable_timer.hpp:382
#2 0x0000021e538a in async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >::~basic_endpoint_impl() async_mqtt/include/async_mqtt/asio_bind/impl/endpoint_impl.hpp:51
#3 0x0000021e5a10 in void std::destroy_at<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >(async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:88
#4 0x0000021dd28c in void std::_Destroy<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >(async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:164
#5 0x0000021a7ba4 in void std::allocator_traits<std::allocator<void> >::destroy<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >(std::allocator<void>&, async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*) /usr/local/gcc12/include/c++/16.0.0/bits/alloc_traits.h:819
#6 0x0000021a7ba4 in std::_Sp_counted_ptr_inplace<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:618
#7 0x000000425e76 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:347
#8 0x00000053038d in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1072
#9 0x0000006aa024 in std::__shared_ptr<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1534
#10 0x0000006aa15f in std::shared_ptr<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >::~shared_ptr() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:175
#11 0x0000021ebc15 in async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >::~basic_endpoint() async_mqtt/include/async_mqtt/asio_bind/impl/endpoint_misc.ipp:517
#12 0x0000021e63ac in void std::destroy_at<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >(async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:88
#13 0x0000021dde7e in void std::_Destroy<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >(async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:164
#14 0x0000021acc0a in void std::allocator_traits<std::allocator<void> >::destroy<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >(std::allocator<void>&, async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*) /usr/local/gcc12/include/c++/16.0.0/bits/alloc_traits.h:819
#15 0x0000021acc0a in std::_Sp_counted_ptr_inplace<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:618
#16 0x000000425e76 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:347
#17 0x00000053038d in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1072
#18 0x00000051963a in std::__shared_ptr<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1534
#19 0x00000051969d in std::shared_ptr<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >::~shared_ptr() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:175
#20 0x00000051ba7a in run_broker(boost::program_options::variables_map const&)::{lambda()#5}::operator()() const::{lambda(boost::system::error_code const&)#1}::~error_code() async_mqtt/tool/broker.cpp:310
#21 0x0000008e5023 in boost::asio::detail::binder1<run_broker(boost::program_options::variables_map const&)::{lambda()#5}::operator()() const::{lambda(boost::system::error_code const&)#1}, boost::system::error_code>::~binder1() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/bind_handler.hpp:139
#22 0x0000008e55f1 in boost::asio::detail::reactive_socket_accept_op<boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ip::tcp, run_broker(boost::program_options::variables_map const&)::{lambda()#5}::operator()() const::{lambda(boost::system::error_code const&)#1}, boost::asio::any_io_executor>::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) async_mqtt/boost_1_82_0/install/include/boost/asio/detail/reactive_socket_accept_op.hpp:158
#23 0x00000043b37a in boost::asio::detail::scheduler_operation::destroy() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/scheduler_operation.hpp:45
#24 0x000000452e8d in boost::asio::detail::scheduler::shutdown() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/scheduler.ipp:176
#25 0x000000435b0a in boost::asio::detail::service_registry::shutdown_services() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/service_registry.ipp:44
#26 0x000000438311 in boost::asio::execution_context::shutdown() async_mqtt/boost_1_82_0/install/include/boost/asio/impl/execution_context.ipp:41
#27 0x00000045baa5 in boost::asio::io_context::~io_context() async_mqtt/boost_1_82_0/install/include/boost/asio/impl/io_context.ipp:58
#28 0x000000526a32 in run_broker(boost::program_options::variables_map const&) async_mqtt/tool/broker.cpp:804
#29 0x000000415b41 in main async_mqtt/tool/broker.cpp:1007
#30 0x7f72ee9730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) (BuildId: 099b9225bcb0d019d9d60884be583eb31bb5f44e)
#31 0x00000041161d in _start (async_mqtt/build_openssl/tool/broker+0x41161d)
0x7bf2edee0ea0 is located 0 bytes inside of 96-byte region [0x7bf2edee0ea0,0x7bf2edee0f00)
freed by thread T0 here:
#0 0x7f72efaae337 in operator delete(void*, unsigned long) ../../.././libsanitizer/asan/asan_new_delete.cpp:155
#1 0x0000021d0408 in boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >::~deadline_timer_service() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/deadline_timer_service.hpp:82
#2 0x000000436548 in boost::asio::detail::service_registry::destroy(boost::asio::execution_context::service*) async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/service_registry.ipp:110
#3 0x000000435e3d in boost::asio::detail::service_registry::destroy_services() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/service_registry.ipp:54
#4 0x000000438399 in boost::asio::execution_context::destroy() async_mqtt/boost_1_82_0/install/include/boost/asio/impl/execution_context.ipp:46
#5 0x0000004381e2 in boost::asio::execution_context::~execution_context() async_mqtt/boost_1_82_0/install/include/boost/asio/impl/execution_context.ipp:35
#6 0x00000045baf4 in boost::asio::io_context::~io_context() async_mqtt/boost_1_82_0/install/include/boost/asio/impl/io_context.ipp:59
#7 0x0000021e63ec in void std::destroy_at<boost::asio::io_context>(boost::asio::io_context*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:88
#8 0x0000021dde99 in void std::_Destroy<boost::asio::io_context>(boost::asio::io_context*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:164
#9 0x0000021ad492 in void std::allocator_traits<std::allocator<void> >::destroy<boost::asio::io_context>(std::allocator<void>&, boost::asio::io_context*) /usr/local/gcc12/include/c++/16.0.0/bits/alloc_traits.h:819
#10 0x0000021ad492 in std::_Sp_counted_ptr_inplace<boost::asio::io_context, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:618
#11 0x000000425e76 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:347
#12 0x00000053038d in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1072
#13 0x0000004de5c0 in std::__shared_ptr<boost::asio::io_context, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1534
#14 0x0000004de623 in std::shared_ptr<boost::asio::io_context>::~shared_ptr() /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:175
#15 0x0000008054c6 in void std::destroy_at<std::shared_ptr<boost::asio::io_context> >(std::shared_ptr<boost::asio::io_context>*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:88
#16 0x0000007514a8 in void std::_Destroy<std::shared_ptr<boost::asio::io_context> >(std::shared_ptr<boost::asio::io_context>*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:164
#17 0x00000069816a in void std::_Destroy<std::shared_ptr<boost::asio::io_context>*>(std::shared_ptr<boost::asio::io_context>*, std::shared_ptr<boost::asio::io_context>*) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:226
#18 0x000000591865 in void std::_Destroy<std::shared_ptr<boost::asio::io_context>*, std::shared_ptr<boost::asio::io_context> >(std::shared_ptr<boost::asio::io_context>*, std::shared_ptr<boost::asio::io_context>*, std::allocator<std::shared_ptr<boost::asio::io_context> >&) /usr/local/gcc12/include/c++/16.0.0/bits/alloc_traits.h:1045
#19 0x000000591865 in std::vector<std::shared_ptr<boost::asio::io_context>, std::allocator<std::shared_ptr<boost::asio::io_context> > >::~vector() /usr/local/gcc12/include/c++/16.0.0/bits/stl_vector.h:792
#20 0x000000526a1b in run_broker(boost::program_options::variables_map const&) async_mqtt/tool/broker.cpp:804
#21 0x000000415b41 in main async_mqtt/tool/broker.cpp:1007
#22 0x7f72ee9730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) (BuildId: 099b9225bcb0d019d9d60884be583eb31bb5f44e)
previously allocated by thread T0 here:
#0 0x7f72efaad3cf in operator new(unsigned long) ../../.././libsanitizer/asan/asan_new_delete.cpp:86
#1 0x000000898348 in boost::asio::execution_context::service* boost::asio::detail::service_registry::create<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >, boost::asio::execution_context>(void*) async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/service_registry.hpp:87
#2 0x000000436901 in boost::asio::detail::service_registry::do_use_service(boost::asio::execution_context::service::key const&, boost::asio::execution_context::service* (*)(void*), void*) async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/service_registry.ipp:132
#3 0x0000007fed60 in boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >& boost::asio::detail::service_registry::use_service<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > > >() async_mqtt/boost_1_82_0/install/include/boost/asio/detail/impl/service_registry.hpp:30
#4 0x00000074abf0 in boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >& boost::asio::use_service<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > > >(boost::asio::execution_context&) async_mqtt/boost_1_82_0/install/include/boost/asio/impl/execution_context.hpp:35
#5 0x000000692e5b in boost::asio::detail::io_object_impl<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >, boost::asio::any_io_executor>::io_object_impl(int, boost::asio::any_io_executor const&) async_mqtt/boost_1_82_0/install/include/boost/asio/detail/io_object_impl.hpp:48
#6 0x00000061f21c in boost::asio::basic_waitable_timer<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock>, boost::asio::any_io_executor>::basic_waitable_timer(boost::asio::any_io_executor const&) async_mqtt/boost_1_82_0/install/include/boost/asio/basic_waitable_timer.hpp:182
#7 0x000000eeaa6f in async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >::basic_endpoint_impl<boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) async_mqtt/include/async_mqtt/asio_bind/impl/endpoint_misc.hpp:41
#8 0x000000e249df in void std::_Construct<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:133
#9 0x000000ca3c34 in void std::allocator_traits<std::allocator<void> >::construct<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::allocator<void>&, async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/alloc_traits.h:805
#10 0x000000ca3c34 in std::_Sp_counted_ptr_inplace<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::allocator<void>, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:609
#11 0x000000c11710 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, std::allocator<void>, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:972
#12 0x000000b7a5e0 in std::__shared_ptr<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::_Sp_alloc_shared_tag<std::allocator<void> >, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1722
#13 0x000000ae0863 in std::shared_ptr<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >::shared_ptr<std::allocator<void>, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::_Sp_alloc_shared_tag<std::allocator<void> >, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:463
#14 0x000000a31807 in std::shared_ptr<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > > std::make_shared<async_mqtt::detail::basic_endpoint_impl<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::protocol_version&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:1008
#15 0x000000990c70 in async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >::basic_endpoint<boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) async_mqtt/include/async_mqtt/asio_bind/impl/endpoint_misc.hpp:113
#16 0x00000091c03d in void std::_Construct<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*, async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/stl_construct.h:133
#17 0x0000008082b8 in void std::allocator_traits<std::allocator<void> >::construct<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::allocator<void>&, async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*, async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/alloc_traits.h:805
#18 0x0000008082b8 in std::_Sp_counted_ptr_inplace<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::allocator<void>, async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:609
#19 0x000000752b84 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, std::allocator<void>, async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:972
#20 0x000000699eac in std::__shared_ptr<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::_Sp_alloc_shared_tag<std::allocator<void> >, async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr_base.h:1722
#21 0x0000006279f5 in std::shared_ptr<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > >::shared_ptr<std::allocator<void>, async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(std::_Sp_alloc_shared_tag<std::allocator<void> >, async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:463
#22 0x000000593e86 in std::shared_ptr<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> > > std::make_shared<async_mqtt::basic_endpoint<(async_mqtt::role)2, 2ul, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, async_mqtt::protocol_version, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >(async_mqtt::protocol_version&&, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> >&&) /usr/local/gcc12/include/c++/16.0.0/bits/shared_ptr.h:1008
#23 0x00000051895b in run_broker(boost::program_options::variables_map const&)::{lambda()#5}::operator()() const async_mqtt/tool/broker.cpp:304
#24 0x0000008527f6 in void std::__invoke_impl<void, run_broker(boost::program_options::variables_map const&)::{lambda()#5}&>(std::__invoke_other, run_broker(boost::program_options::variables_map const&)::{lambda()#5}&) /usr/local/gcc12/include/c++/16.0.0/bits/invoke.h:63
#25 0x0000007b48f6 in std::enable_if<is_invocable_r_v<void, run_broker(boost::program_options::variables_map const&)::{lambda()#5}&>, void>::type std::__invoke_r<void, run_broker(boost::program_options::variables_map const&)::{lambda()#5}&>(run_broker(boost::program_options::variables_map const&)::{lambda()#5}&) /usr/local/gcc12/include/c++/16.0.0/bits/invoke.h:113
#26 0x0000006e62b0 in std::_Function_handler<void (), run_broker(boost::program_options::variables_map const&)::{lambda()#5}>::_M_invoke(std::_Any_data const&) /usr/local/gcc12/include/c++/16.0.0/bits/std_function.h:295
#27 0x000000596510 in std::function<void ()>::operator()() const /usr/local/gcc12/include/c++/16.0.0/bits/std_function.h:581
#28 0x000000523b0d in run_broker(boost::program_options::variables_map const&) async_mqtt/tool/broker.cpp:326
#29 0x000000415b41 in main async_mqtt/tool/broker.cpp:1007
#30 0x7f72ee9730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) (BuildId: 099b9225bcb0d019d9d60884be583eb31bb5f44e)
SUMMARY: AddressSanitizer: heap-use-after-free async_mqtt/boost_1_82_0/install/include/boost/asio/detail/io_object_impl.hpp:97 in boost::asio::detail::io_object_impl<boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >, boost::asio::any_io_executor>::~io_object_impl()
Shadow bytes around the buggy address:
0x7bf2edee0c00: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x7bf2edee0c80: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x7bf2edee0d00: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x7bf2edee0d80: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x7bf2edee0e00: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 fa
=>0x7bf2edee0e80: fa fa fa fa[fd]fd fd fd fd fd fd fd fd fd fd fd
0x7bf2edee0f00: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x7bf2edee0f80: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
0x7bf2edee1000: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
0x7bf2edee1080: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x7bf2edee1100: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==1188484==ABORTING