Call stack:
#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
Anyone encountered this issue, could shed light on why abort happpened in _Unwind_Resume
?
Wrote a simple test to simulate this problem:
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;
}
}
Compile it with g++, and reproduce the _Unwind_Resume
error successfully.
The _Unwind_Resume
error could be ignored by catching the exception in class A
's destructor, see bellow:
~A(){
try {
throwInDestor();
} catch (...) {
std::cout << "A::~A: " << boost::diagnostic_information(boost::current_exception()) << std::endl;
}
};
the std::string
exception was thrown out, and catch handler found in main function. Then the crash happened while doing cleanup work in callf1
while std::string
exception was propagating to main
Because the first exception is in process of unwinding and doing cleanup work, but int
exception was thrown in destructor of A
in function callf1
.
So the solution could be catch the int
exception immediately in A
's destructor, as described above.
I don't know why it works, but it actually works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With