Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

c++ - Why crash inside boost log when program terminate

I have my application using boost logger. When I terminate my program using killall myApplication. There is core file generated. I then use gdb and see the trace. I also tried some related fix but not useful. link

#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=)
? ? 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=, 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=) at /usr/include/boost/log/detail/light_rw_mutex.hpp:115
#9 ?boost::log::v2_mt_posix::sources::multi_thread_model::unlock_shared (this=) at /usr/include/boost/log/sources/threading_models.hpp:78
#10 boost::log::v2_mt_posix::aux::shared_lock_guard >::~shared_lock_guard (this=,
? ? __in_chrg=) at /usr/include/boost/log/detail/locks.hpp:146
#11 boost::log::v2_mt_posix::sources::basic_composite_logger, boost::log::v2_mt_posix::sources::multi_thread_model, boost::log::v2_mt_posix::sources::features > >::open_record > (this=this@entry=0x55c83e46b798, args=...) at /usr/include/boost/log/sources/basic_logger.hpp:458

My application is running on linux. In class destructor, I have log printing. The core file shows that that is the crashing point. I would like to ask if that is some config problem or a wrong usage of the boost library?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem is that at the point when your class destructor is called the thread-local storage used for the severity level is already destroyed. Because of this, initiating a log record fails with an exception, and since you don't catch it, the program aborts.

It is recommended to avoid logging during program termination. However, if you really do need that instance of logging, you may try changing the logger type to logger_mt. This will remove the severity level from the log records emitted through that logger, but you could emulate it with scoped logger attributes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...