为什么程序终止时在提升日志内崩溃



我的应用程序使用boost记录器。当我使用killallmyApplication终止程序时。生成了核心文件。然后我使用gdb并查看跟踪。我也尝试了一些相关的修复,但没有用。链路

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ff95f9aa801 in __GI_abort () at abort.c:79
#2  0x00007ff96240f84a in __gnu_cxx::__verbose_terminate_handler ()
    at /home/nwani/m3/conda-bld/compilers_linux-64_1560109574129/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007ff96240df47 in __cxxabiv1::__terminate (handler=<optimized out>)
    at /home/nwani/m3/conda-bld/compilers_linux-64_1560109574129/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
#4  0x00007ff96240d3a5 in __cxa_call_terminate (ue_header=ue_header@entry=0x55c83e48bfd0)
    at /home/nwani/m3/conda-bld/compilers_linux-64_1560109574129/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/libstdc++-v3/libsupc++/eh_call.cc:54
#5  0x00007ff96240dbd8 in __cxxabiv1::__gxx_personality_v0 (version=<optimized out>, actions=6, exception_class=5138137972254386944, ue_header=0x55c83e48bfd0, context=0x7ffc786aaa90)
    at /home/nwani/m3/conda-bld/compilers_linux-64_1560109574129/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/libstdc++-v3/libsupc++/eh_personality.cc:677
#6  0x00007ff96235aaab in _Unwind_RaiseException_Phase2 (exc=exc@entry=0x55c83e48bfd0, context=context@entry=0x7ffc786aaa90, frames_p=frames_p@entry=0x7ffc786aa998)
    at /home/nwani/m3/conda-bld/compilers_linux-64_1560109574129/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/libgcc/unwind.inc:64
#7  0x00007ff96235af49 in _Unwind_Resume (exc=0x55c83e48bfd0) at /home/nwani/m3/conda-bld/compilers_linux-64_1560109574129/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/libgcc/unwind.inc:241
#8  0x000055c83c2e5be1 in boost::log::v2_mt_posix::aux::light_rw_mutex::unlock_shared (this=<optimized out>) at /usr/include/boost/log/detail/light_rw_mutex.hpp:115
#9  boost::log::v2_mt_posix::sources::multi_thread_model<boost::log::v2_mt_posix::aux::light_rw_mutex>::unlock_shared (this=<optimized out>) at /usr/include/boost/log/sources/threading_models.hpp:78
#10 boost::log::v2_mt_posix::aux::shared_lock_guard<boost::log::v2_mt_posix::sources::multi_thread_model<boost::log::v2_mt_posix::aux::light_rw_mutex> >::~shared_lock_guard (this=<optimized out>,
    __in_chrg=<optimized out>) at /usr/include/boost/log/detail/locks.hpp:146
#11 boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_logger_mt<severity_level>, boost::log::v2_mt_posix::sources::multi_thread_model<boost::log::v2_mt_posix::aux::light_rw_mutex>, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<severity_level> > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, severity_level const> > (this=this@entry=0x55c83e46b798, args=...) at /usr/include/boost/log/sources/basic_logger.hpp:458

我的应用程序正在linux上运行。在类析构函数中,我有日志打印。核心文件显示这就是崩溃点。我想问一下,这是配置问题还是boost库的错误使用?

问题是,在调用类析构函数时,用于严重级别的线程本地存储已经被破坏。因此,启动日志记录会失败并出现异常,并且由于您没有捕获它,程序将中止。

建议避免在程序终止期间进行日志记录。但是,如果您确实需要该日志记录实例,可以尝试将记录器类型更改为logger_mt。这将从通过该记录器发出的日志记录中删除严重性级别,但您可以使用作用域记录器属性来模拟它。

最新更新