从分段错误中恢复的最佳实践
我正在开发一个用 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.
相关文章