2013-02-22 14 views
0

調用堆棧:應用程序崩潰與中止錯誤從_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中止happpened光?

+2

也許是因爲124行文件'../ trogdor/servlets/server.cpp'中的某個問題?看起來像一個未捕獲的異常。 – 2013-02-22 02:01:29

+0

未找到任何明確的未捕獲異常。 – tsing 2013-02-24 04:06:33

+0

您能否顯示'〜ServletRequest'析構函數?還有其中使用的任何變量的聲明? – 2013-02-24 05:01:14

回答

2

寫了一個簡單的測試來模擬這樣的問題:

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錯誤。 的_Unwind_Resume錯誤可以通過捕捉在class A的析構函數的異常被忽略,參見下文:

~A(){ 
    try { 
     throwInDestor(); 
    } catch (...) { 
     std::cout << "A::~A: " << boost::diagnostic_information(boost::current_exception()) << std::endl; 
    } 
}; 

std::string異常被拋出,以及捕獲處理程序的主要功能找到。然後在執行清理工作callf1時發生了崩潰,而std::string異常傳播到主要 由於第一個異常正在展開和清理工作,但在A的函數callf1中拋出了int異常。 因此,解決方案可以在A的析構函數中立即捕獲int異常,如上所述。

我不知道它爲什麼會起作用,但它確實有效。

+0

1)永遠不要扔析構函數。 2)不要在沒有重新拋出的情況下用catch-all子句('...')來捕獲異常。 – 2013-02-25 03:44:12

+0

在析構函數中拋出異常只是爲了模擬_Unwind_Resume中止錯誤。 – tsing 2013-02-25 08:36:42

+0

你一定是在跟我開玩笑...... – 2013-02-25 12:49:48

相關問題