I have a network client that uses Asio and its thread pool to manage two connection objects. The thread pool has 2 threads.
I have a series of tests that randomly fail with what I feel is a strange error:
Process 2735 stopped
* thread #2, stop reason = EXC_BAD_ACCESS (code=1, address=0x1)
frame #0: 0x0000000000000001
error: memory read failed for 0x0
Target 0: (integration) stopped.
(lldb) bt
* thread #2, stop reason = EXC_BAD_ACCESS (code=1, address=0x1)
* frame #0: 0x0000000000000001
frame #1: 0x000000010000b897 integration`asio::detail::scheduler_operation::complete(this=0x00000001004e2210, owner=0x0000000100c016f0, ec=0x00007000053a0aa8, bytes_transferred=0) at scheduler_operation.hpp:39
frame #2: 0x000000010000aba9 integration`asio::detail::scheduler::do_run_one(this=0x0000000100c016f0, lock=0x00007000053a09c8, this_thread=0x00007000053a0a00, ec=0x00007000053a0aa8) at scheduler.ipp:400
frame #3: 0x000000010000a7d3 integration`asio::detail::scheduler::run(this=0x0000000100c016f0, ec=0x00007000053a0aa8) at scheduler.ipp:153
frame #4: 0x000000010000e1d0 integration`asio::io_context::run(this=0x0000000100c015d8) at io_context.ipp:61
frame #5: 0x000000010000e16f integration`dbc::detail::pool::pool(this=0x00007000053a0b50)::$_0::operator()() const at pool.cpp:26
frame #6: 0x000000010000e145 integration`void asio::asio_handler_invoke<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0>(function=0x00007000053a0b50)::$_0&, ...) at handler_invoke_hook.hpp:68
frame #7: 0x000000010000e127 integration`void asio_handler_invoke_helpers::invoke<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0, dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0>(function=0x00007000053a0b50, context=0x00007000053a0b50)::$_0&, dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0&) at handler_invoke_helpers.hpp:37
frame #8: 0x000000010000e0ae integration`void asio::system_executor::dispatch<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0, std::__1::allocator<void> >(this=0x00007000053a0b90, f=0x00007000053a0c28, (null)=0x00007000053a0ba0)::$_0&&, std::__1::allocator<void> const&) const at system_executor.hpp:38
frame #9: 0x000000010000e054 integration`asio::detail::work_dispatcher<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0>::operator(this=0x00007000053a0c20)() at work_dispatcher.hpp:57
frame #10: 0x000000010000e005 integration`void asio::asio_handler_invoke<asio::detail::work_dispatcher<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0> >(function=0x00007000053a0c20)::$_0>&, ...) at handler_invoke_hook.hpp:68
frame #11: 0x000000010000de57 integration`void asio_handler_invoke_helpers::invoke<asio::detail::work_dispatcher<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0>, asio::detail::work_dispatcher<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0> >(function=0x00007000053a0c20, context=0x00007000053a0c20)::$_0>&, asio::detail::work_dispatcher<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0>&) at handler_invoke_helpers.hpp:37
frame #12: 0x000000010000dcc1 integration`asio::detail::executor_op<asio::detail::work_dispatcher<dbc::detail::pool::pool(dbc::pool_parameters, dbc::db_parameters)::$_0>, std::__1::allocator<void>, asio::detail::scheduler_operation>::do_complete(owner=0x0000000100c01860, base=0x0000000100c019c0, (null)=0x00007000053a0e98, (null)=0) at executor_op.hpp:69
frame #13: 0x000000010000b897 integration`asio::detail::scheduler_operation::complete(this=0x0000000100c019c0, owner=0x0000000100c01860, ec=0x00007000053a0e98, bytes_transferred=0) at scheduler_operation.hpp:39
frame #14: 0x000000010000aba9 integration`asio::detail::scheduler::do_run_one(this=0x0000000100c01860, lock=0x00007000053a0db8, this_thread=0x00007000053a0df0, ec=0x00007000053a0e98) at scheduler.ipp:400
frame #15: 0x000000010000a7d3 integration`asio::detail::scheduler::run(this=0x0000000100c01860, ec=0x00007000053a0e98) at scheduler.ipp:153
frame #16: 0x000000010000a61f integration`asio::thread_pool::thread_function::operator(this=0x0000000100c005e8)() at thread_pool.ipp:32
frame #17: 0x000000010000a5c9 integration`asio::detail::posix_thread::func<asio::thread_pool::thread_function>::run(this=0x0000000100c005e0) at posix_thread.hpp:85
frame #18: 0x000000010000a4e1 integration`asio_detail_posix_thread_function(arg=0x0000000100c005e0) at posix_thread.ipp:73
frame #19: 0x00007fff6f64e305 libsystem_pthread.dylib`_pthread_body + 126
frame #20: 0x00007fff6f65126f libsystem_pthread.dylib`_pthread_start + 70
frame #21: 0x00007fff6f64d415 libsystem_pthread.dylib`thread_start + 13
The only connection to my code is on frame #5 which corresponds to where I start the io_context in the thread pool:
pool::pool(pool_parameters config, db_parameters params) noexcept
: m_config{std::move(config)},
m_params{std::move(params)},
m_workers{m_config.thread_pool_size},
m_work_guard{asio::make_work_guard(m_io_context)} {
asio::post(m_workers, [&]() { m_io_context.run(); });
m_connections.reserve(0);
m_connections.shrink_to_fit();
}
(frame #5 is asio::post
)
How can I debug this?
Aucun commentaire:
Enregistrer un commentaire