c++ - 来自 backtrace 的堆栈跟踪未显示在多线程环境下导致崩溃的方法

标签 c++ boost-asio debug-symbols backtrace debug-backtrace

我试图准确捕获哪个方法,或者至少是哪个类使我的代码崩溃
回溯在收到 SIGSEGV 信号后返回的消息。是不是因为崩溃的方法在另一个线程上执行,因此回溯无法这样做(请参阅我的日志的第一行 - 进程 ID 是 7fdae0268700,我在那里添加了代码以使我的应用程序崩溃)?请问对这个问题有什么建议吗?

    2013-03-07 17:43:42.863709502 [7fdae0268700] DEBUG data_service - I Crash You! Location
    2013-03-07 17:43:42.863804548 [7fdae7d1c720] INFO  service_runner - Receive signal 11
    2013-03-07 17:43:42.870357301 [7fdae7d1c720] DEBUG service_runner - [bt]: (0) ../Debug/MyAppService : my_app_service_lib::service_runner::handle_crash_stop(boost::system::error_code const&, int)+0x7e [0xcccf54]
    2013-03-07 17:43:42.870369392 [7fdae7d1c720] DEBUG service_runner - [bt]: (1) ../Debug/MyAppService : boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>::operator()(my_app_service_lib::service_runner*, boost::system::error_code const&, int) const+0x74 [0xcd8278]
    2013-03-07 17:43:42.870384611 [7fdae7d1c720] DEBUG service_runner - [bt]: (2) ../Debug/MyAppService : void boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> >::operator()<boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list2<boost::system::error_code const&, int const&> >(boost::_bi::type<void>, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>&, boost::_bi::list2<boost::system::error_code const&, int const&>&, int)+0x7c [0xcd80c6]
    2013-03-07 17:43:42.870395158 [7fdae7d1c720] DEBUG service_runner - [bt]: (3) ../Debug/MyAppService : void boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >::operator()<boost::system::error_code, int>(boost::system::error_code const&, int const&)+0x4c [0xcd7f0e]
    2013-03-07 17:43:42.870405480 [7fdae7d1c720] DEBUG service_runner - [bt]: (4) ../Debug/MyAppService : boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int>::operator()()+0x2b [0xcd7e15]
    2013-03-07 17:43:42.870419010 [7fdae7d1c720] DEBUG service_runner - [bt]: (5) ../Debug/MyAppService : void boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int> >(boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int>, ...)+0x62 [0xcd7d2e]
    2013-03-07 17:43:42.870436180 [7fdae7d1c720] DEBUG service_runner - [bt]: (6) ../Debug/MyAppService : void boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int>, boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > > >(boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int>&, boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > >&)+0x64 [0xcd7bea]
    2013-03-07 17:43:42.870447863 [7fdae7d1c720] DEBUG service_runner - [bt]: (7) ../Debug/MyAppService : boost::asio::detail::signal_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, my_app_service_lib::service_runner, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<my_app_service_lib::service_runner*>, boost::arg<1>, boost::arg<2> > > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long)+0xb9 [0xcd78db]
    2013-03-07 17:43:42.870454915 [7fdae7d1c720] DEBUG service_runner - [bt]: (8) ../Debug/MyAppService : boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long)+0x32 [0xcce3ba]
    2013-03-07 17:43:42.870462704 [7fdae7d1c720] DEBUG service_runner - [bt]: (9) ../Debug/MyAppService : boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service::thread_info&, boost::system::error_code const&)+0x1a1 [0xcd09b3]
    2013-03-07 17:43:42.870469226 [7fdae7d1c720] DEBUG service_runner - [bt]: (10) ../Debug/MyAppService : boost::asio::detail::task_io_service::run(boost::system::error_code&)+0x137 [0xcd050b]
    2013-03-07 17:43:42.870474974 [7fdae7d1c720] DEBUG service_runner - [bt]: (11) ../Debug/MyAppService : boost::asio::io_service::run()+0x2f [0xcd0d31]
    2013-03-07 17:43:42.870480654 [7fdae7d1c720] DEBUG service_runner - [bt]: (12) ../Debug/MyAppService : my_app_service_lib::service_runner::run()+0x97 [0xcccda9]
    2013-03-07 17:43:42.870486438 [7fdae7d1c720] DEBUG service_runner - [bt]: (13) ../Debug/MyAppService : main+0x4cc [0xcc5838]
    2013-03-07 17:43:42.870491274 [7fdae7d1c720] DEBUG service_runner - [bt]: (14) /lib64/libc.so.6 : __libc_start_main+0xfd [0x3f0f01ecdd]
    2013-03-07 17:43:42.870495884 [7fdae7d1c720] DEBUG service_runner - [bt]: (15) ../Debug/MyAppService() [0xcc5289]

最佳答案

如果您使用由 boost::asio::signal_set::async_wait 调用的处理程序调用backtrace_symbols(3)这是行不通的。 signal_set 类使用 signalfd在 Linux 上,其他平台可能会使用 pipe-select-interrupt 技巧,具体我不知道。因此,当您的处理程序被调用时,它不会来自导致 SEGV 的线程。

通常不建议在遇到 SEGV 信号时尝试做任何聪明/可爱的事情。你不能 reliably continue execution .我建议不要处理 SEGV 信号,而是在进程异常终止时将系统配置为核心转储,然后分析核心转储。

关于c++ - 来自 backtrace 的堆栈跟踪未显示在多线程环境下导致崩溃的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15268201/

相关文章:

c++ - 没有 () 的访问器,或对成员变量的 const 引用

c++ - 本地 Windows 调试器替换为附加,无法运行和调试我的程序

c++ - 基于派生类型的编译时行为分支

c# - Visual Studio 调试器,在 ASP 经典页面启动 w3wp 时未加载符号

.net - .NET 垃圾收集器在使用调试符号发布版本时是否不那么激进?

c++ - 将整数的二进制数据转换为 float

c++ - Asio 中新连接出现 "Already Open"错误

c++ - 帮助在 C++ 中通过 http 流式传输

c++ - 标准输入按键的 asio 服务处理程序

python - 如何为 Windows 获取预构建的 *debug* 版本的 Python 库(例如 Python27_d.dll)