Best practices for recovering from a segmentation fault(从分段错误中恢复的最佳实践)
问题描述
我正在开发一个用 C++ 编写的多线程进程,并且正在考虑使用 google 修改 SIGSEGV 处理-coredumper 在发生分段错误时保持进程处于活动状态.
I am working on a multithreaded process written in C++, and am considering modifying SIGSEGV handling using google-coredumper to keep the process alive when a segmentation fault occurs.
但是,除非我以某种方式重新初始化可能导致核心转储的线程和对象,否则 google-coredumper 的这种使用似乎已经成熟,有机会陷入核心转储的无限循环.
However, this use of google-coredumper seems ripe with opportunities to get stuck in an infinite loop of core dumps unless I somehow reinitialize the thread and the object that may have caused the core dump.
在尝试通过核心转储保持进程活动时,我应该牢记哪些最佳做法?我还应该注意哪些其他陷阱"?
What best practices should I keep in mind when trying to keep a process alive through a core dump? What other 'gotchas' should I be aware of?
谢谢!
推荐答案
最佳实践是修复导致核心转储的原始问题,重新编译然后重新启动应用程序.
The best practice is to fix the original issue causing the core dump, recompile and then relaunch the application.
要在实际部署之前发现这些错误,请进行大量同行评审并编写大量测试.
To catch these errors before deploying in the wild, do plenty of peer review and write lots of tests.
这篇关于从分段错误中恢复的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从分段错误中恢复的最佳实践
基础教程推荐
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
