确实很奇怪
我这边最开始没问题。
因为查一个问题,然后我把boost 1.81重新编译了一次,就出现了在m_timer的构造函数里面引用boost::asio::detail::scheduler::init_task()时遇到空指针的情况。
正好还保留了当时的一个栈
Thread 1 "my_agent" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x00000000004eccac in boost::asio::detail::scheduler::init_task (this=0xfffff7e36940) at /home/parallels/work/my_linux_agent/my_libs/out_arm64/boost/include/boost/asio/detail/impl/scheduler.ipp:188
#2 0x00000000004eb2e8 in boost::asio::detail::epoll_reactor::init_task (this=0xfffff7fcbdc0)
at /home/parallels/work/my_linux_agent/my_libs/out_arm64/boost/include/boost/asio/detail/impl/epoll_reactor.ipp:149
#3 0x00000000004f95a8 in boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >::deadline_timer_service (this=0xfffff7e35af0, context=...)
at /home/parallels/work/my_linux_agent/my_libs/out_arm64/boost/include/boost/asio/detail/deadline_timer_service.hpp:74
#4 0x00000000004f8584 in boost::asio::detail::service_registry::create<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >, boost::asio::io_context> (
owner=0xfffff7fe5e18) at /home/parallels/work/my_linux_agent/my_libs/out_arm64/boost/include/boost/asio/detail/impl/service_registry.hpp:87
#5 0x00000000004e9748 in boost::asio::detail::service_registry::do_use_service (this=0xfffff7fc7200, key=...,
factory=0x4f8550 <boost::asio::detail::service_registry::create<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >, boost::asio::io_context>(void*)>,
owner=0xfffff7fe5e18) at /home/parallels/work/my_linux_agent/my_libs/out_arm64/boost/include/boost/asio/detail/impl/service_registry.ipp:132
#6 0x0000000000759644 in boost::asio::detail::service_registry::use_service<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> > > (owner=..., this=<optimized out>)
at ../../../../out_arm64/boost/include/boost/asio/detail/impl/service_registry.hpp:76
#7 boost::asio::use_service<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> > > (ioc=...) at ../../../../out_arm64/boost/include/boost/asio/impl/io_context.hpp:42
#8 boost::asio::detail::io_object_impl<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boot::asio::execution_context&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0> >, boost::asio::execution::prefer_only<oost::asio::execution::detail::outstanding_work::tracked_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0> >, boost::asio::execution::prefer_only<boost::asi::execution::detail::relationship::fork_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0> > > >::io_object_impl<boost::asio::io_context> (context=...,
this=0xfffff7fe5e78) at ../../../../out_arm64/boost/include/boost/asio/detail/io_object_impl.hpp:60
#9 boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boost::asio::execution_cotext&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution:detail::outstanding_work::tracked_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::elationship::fork_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0> > > >::basic_deadline_timer<boost::asio::io_context> (context=...,
this=0xfffff7fe5e78) at ../../../../out_arm64/boost/include/boost/asio/basic_deadline_timer.hpp:182
#10 NFProxy::NFProxy (this=0xfffff7fe5dd0, pEventHandler=0x1a9ef80 <g_proxy>) at ./nfproxy.h:1179
#11 0x00000000007516c4 in startProxy (pHandler=0x1a9ef80 <g_proxy>) at ./nfproxy.cpp:41
#12 nfapi::nf_init (driverName=<optimized out>, pHandler=0x1a9ef80 <g_proxy>) at ./nfproxy.cpp:83
#13 0x00000000004cd2fc in CNetFilter::StartInternal (this=0x1593f38 <CNetFilter::GetInstance()::filter>) at /home/parallels/work/my_linux_agent/daemon/netfilter/CNetFilter.cpp:181
#14 0x00000000004cce90 in CNetFilter::Start (this=0x1593f38 <CNetFilter::GetInstance()::filter>) at /home/parallels/work/my_linux_agent/daemon/netfilter/CNetFilter.cpp:129
#15 0x0000000000413b14 in CmyAgent::EnableSubModules (this=0x1a94ea8 <CmyAgent::GetInstance()::instance>) at /home/parallels/work/my_linux_agent/daemon/agent.cpp:583
#16 0x00000000004135d4 in CmyAgent::EnableAgent (this=0x1a94ea8 <CmyAgent::GetInstance()::instance>) at /home/parallels/work/my_linux_agent/daemon/agent.cpp:508
#17 0x0000000000410a78 in CmyAgent::WorkLoop (this=0x1a94ea8 <CmyAgent::GetInstance()::instance>) at /home/parallels/work/my_linux_agent/daemon/agent.cpp:115
#18 0x00000000004b4dcc in app_running () at /home/parallels/work/my_linux_agent/daemon/main.cpp:16
#19 0x00000000004b4fd0 in main (argc=1, args=0xfffffffff628) at /home/parallels/work/my_linux_agent/daemon/main.cpp:50
(gdb)
【 在 weiwallz 的大作中提到: 】
: 按理说不应该啊,m_io_context声明在先,所以到了m_timer的时候,m_io_context应该已经初始化了啊
:
--
修改:z16166 FROM 221.218.163.*
FROM 221.218.163.*