Why my application crashes on process termination when file sinks are used?
来源:互联网 发布:android需要看java书籍 编辑:程序博客网 时间:2024/03/29 05:40
There are known problems with Boost.Filesystem (for example, #8642 and #9219), which affect Boost.Log file sink backends. When the file sink is destroyed, it attempts to perform a final log file rotation, which involvesBoost.Filesystem for moving files. This typically happens when Boost.Log core is deinitialized, at the global deinitialization stage, after leavingmain()
. The crux of the problem is thatBoost.Filesystem uses a global locale object internally to perform character code conversion forpath
s, and this locale may get destroyed before Boost.Log is deinitialized, which results in a crash.
There is no way for Boost.Log to influence the order of global deinitialization, but the problem can be worked around on the user's side. One solution is to make sure the locale is initializedbefore Boost.Log. This can be achieved by callingboost::filesystem::path::codecvt()
or boost::filesystem::path::imbue()
early during the application startup, before performing any calls to Boost.Log. For example:
int main(int argc, char* argv[]){ boost::filesystem::path::imbue(std::locale("C")); initialize_log(); // ...}
Note that in this case you can't use Boost.Log in global constructors or you have to make sure thatboost::filesystem::path::imbue()
is still called first.
Another solution is to remove and destroy file sinks from the logging core before returning frommain()
. This way file rotation will happen before leavingmain()
, while the locale is still valid. The file sinks can be removed either individually or as a part of theremove_all_sinks()
call:
int main(int argc, char* argv[]){ // ... logging::core::get()->remove_all_sinks(); return 0;}
- Why my application crashes on process termination when file sinks are used?
- How are the icon files in my application bundle used on iPad and iPhone?
- How are the icon files in my application bundle used on iPad and iPhone
- Why are leap years used?
- 每日刷题(2015/6/23)You are given the source to an application which crashes when it is run.
- Automatically Capturing a Dump When a Process Crashes
- Why are pointers used in C++?
- Matlab R2008a crashes when using Plot on MacBook Pro
- zero copy architecture of my video process application on TI 8168 using C6runLib
- IE8 Crashes on Cab File Installation using <OBJECT> tag
- How to fix OpenGL ES application crashes when moving to the background
- ccah-500 第43题 file read process when a client application connects into the cluster and requests a
- CTooltipCtrl crashes on Win98
- 10.2 Application termination
- iOS extracts: Application Termination
- how to find the corresponding libraries are linked to when some APIs are used(2.0)
- how to find the corresponding libraries are linked to when some APIs are used(3.0)
- Why does my OSG MFC based application show memory leaks
- Address already in use: JVM_Bind(端口冲突)
- SQLServer2005外键约束和级联删除
- 代码片段1
- 离散数学学习笔记1
- 1071. Speech Patterns (25)
- Why my application crashes on process termination when file sinks are used?
- How To Make a Simple iPhone Game with Flash CS5
- 陈利人 面试题 对于一个n位正整数a,去掉其中任意k(k<=n)个数字后,剩下的数字按原次序排列可以组成一个新的正整数。设计一个删数算法,使得剩下的数字组成的正整数最小。
- 设计模式OO基础原则模式
- 1.范磊的C++从新手到高手的章节
- ASP.NET网站如何设置404错误页面
- z-index 属性
- 今天心情不好
- Impala学习--代码生成(Code Generation)