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.
这篇关于从分段错误中恢复的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从分段错误中恢复的最佳实践
基础教程推荐
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01