应用程序因_Unwind_Resume中的中止错误而崩溃
Application crashed with abort error from _Unwind_Resume
调用堆栈:
#0 0x00007faf7fdb8ed5 in raise () from /lib/libc.so.6
#1 0x00007faf7fdba3f3 in abort () from /lib/libc.so.6
#2 0x00007faf8063c294 in _gnu_cxx::_verbose_terminate_handler () from /usr/lib/libstdc++.so.6
#3 0x00007faf8063a696 in ?? () from /usr/lib/libstdc++.so.6
#4 0x00007faf8063988b in ?? () from /usr/lib/libstdc++.so.6
#5 0x00007faf8063a458 in _gxx_personality_v0 () from /usr/lib/libstdc++.so.6
#6 0x00007faf800eacb3 in ?? () from /lib/libgcc_s.so.1
#7 0x00007faf800ead78 in _Unwind_Resume () from /lib/libgcc_s.so.1
#8 0x0000000000a0ea6c in ~ServletRequest (this=0x7faf60a156c0) at ../myapp/servlets/server.cpp:124
#9 0x00000000009d8be2 in boost::detail::sp_counted_impl_p<MyApp::ServletRequest>::dispose (this=<value optimized out> at /usr/include/boost/checked_delete.hpp:34
#10 0x00000000006f5569 in ~shared_count (this=<value optimized out> at /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:145
#11 0x00000000009d4a59 in MyApp::Dispatcher::request (this=0x19413b8, req={px = 0x7faf732dfc70, pn = {pi = 0x7faf732dfb60}}) at /usr/include/boost/smart_ptr/shared_ptr.hpp:169
#12 0x00000000009afd9e in boost::detail::function::void_function_ref_invoker1<MyApp::Dispatcher, void, boost::shared_ptr<MyLib::HTTP::ServerRequest> >::invoke (function_obj_ptr=<value optimized out>, a0=<value optimized out> at ../libtriton/mordor/mordor/http/servlet.h:28
#13 0x0000000000cd2bb3 in boost::function1<void, boost::shared_ptr<MyLib::HTTP::ServerRequest> >::operator() (this=<value optimized out>, a0=<value optimized out> at /usr/include/boost/function/function_template.hpp:1013
任何人遇到这个问题,都可以了解为什么_Unwind_Resume
中会出现中止?
编写一个简单的测试来模拟这个问题:
class A {
public:
typedef boost::shared_ptr<A> ptr;
A(std::string name = "default") : m_name(name) { }
void throwInDestor() {
if (m_name == "throwInDestructor")
throw 34;
}
~A(){
throwInDestor();
};
void throwName() {
throw m_name;
}
std::string m_name;
};
void callfunc(A::ptr a) {
a->throwName();
}
void callf1(A::ptr a) {
A::ptr b(new A("throwInDestructor"));
callfunc(a);
}
void callf2() {
A::ptr a(new A("call2"));
callf1(a);
}
int main() {
try {
try {
callf2();
} catch (...) {
std::cout << "inner: " << boost::diagnostic_information(boost::current_exception()) << std::endl;
}
} catch (...) {
std::cout << "outer: " << boost::diagnostic_information(boost::current_exception()) << std::endl;
}
}
用g++编译,成功再现_Unwind_Resume
错误。通过在class A
的析构函数中捕获异常,可以忽略_Unwind_Resume
错误,如下所示:
~A(){
try {
throwInDestor();
} catch (...) {
std::cout << "A::~A: " << boost::diagnostic_information(boost::current_exception()) << std::endl;
}
};
抛出了std::string
异常,并在主函数中找到了catch处理程序。然后在callf1
中执行清理工作时发生崩溃,而std::string
异常正在传播到main因为第一个异常正在展开和执行清理工作,但函数callf1
中A
的析构函数中抛出了int
异常。因此,解决方案可以是在A
的析构函数中立即捕获int
异常,如上所述。
我不知道为什么它有效,但它确实有效。
相关文章:
- 程序崩溃并显示"std::out_of_range"错误
- 防止在C++中选择错误文件时提升 xml 解析器崩溃
- 调用 java 的回调() 时应用程序崩溃.由于 detatchThread 而获得运行时错误
- 比较迭代器会使程序崩溃,而不会在自定义气泡排序实现中出现错误
- 即使有 0 个错误,Getter 似乎也会使程序崩溃
- cv::namedWindow() 崩溃,分段错误
- 由于指针算法错误,代码在 memcpy 中崩溃
- python-clang 崩溃并出现分段错误
- Android (ART) 崩溃并显示错误 JNI 在应用程序中检测到错误:jstring 是无效的本地引用
- C++如果调用 vector,矢量分割错误会导致崩溃
- libcurl curl_easy_perform崩溃(分段错误)c++
- C++ rezing 动态数组最多可以处理一定数量的元素,但在某些时候会崩溃并显示错误 (0XC0000005)
- 从转码示例中使用时,比例过滤器会带有错误崩溃
- 在函数内部错误定位后,从函数中释放返回的指针会导致芯片崩溃
- 函数和指针帮助:程序生成,但崩溃,没有任何特定错误
- React 本机 0.59 应用程序崩溃并出现 libc 错误
- 为什么输出错误崩溃
- 如何调试 gRPC 服务器崩溃而没有任何错误
- 如果ConstexPR编译了错误分支的时间崩溃
- 添加MFC到现有的Win32 c++导致错误/崩溃