我有一个退出处理程序线程等待工作线程执行其工作的条件.信令是从工作线程的析构函数完成的.
下面是退出处理程序线程的代码.
void Class::TaskExitHandler::run() throw()
{
while( ! isInterrupted() ) {
_book->_eot_cond.wait(); // Waiting on this condition
{
CLASS_NAMESPACE::Guard<:fastlock> eguard(_book->_exitlist_lock);
list::const_iterator itr = _book->_exited_tasks.begin();
for( ; itr != _book->_exited_tasks.end(); itr++ ) {
(*itr)->join();
TRACER(TRC_DEBUG)<< "Deleting exited task:" << (*itr)->getLoc() << ":"
<< (*itr)->getTestID() << ":" << (*itr)->getReportName() << endl;
delete (*itr);
}
_book->_exited_tasks.clear();
}
_book->executeAny();
}
}
}
现在,观察到的是当工作线程捕获任何异常(从较低层引发)时,该线程继续,并立即使用退出代码134(SIGABRT)进行核心处理.
堆栈跟踪如下 –
#0 0x0000005555f49b4c in raise () from /lib64/libc.so.6
#1 0x0000005555f4b568 in abort () from /lib64/libc.so.6
#2 0x0000005555d848b4 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib64/libstdc++.so.6
#3 0x0000005555d82210 in ?? () from /usr/lib64/libstdc++.so.6
#4 0x0000005555d82258 in std::terminate () from /usr/lib64/libstdc++.so.6
#5 0x0000005555d82278 in ?? () from /usr/lib64/libstdc++.so.6
#6 0x0000005555d81b18 in __cxa_call_unexpected () from /usr/lib64/libstdc++.so.6
#7 0x0000000120047898 in Class::TaskExitHandler::run ()
#8 0x000000012001cd38 in commutil::ThreadBase::thread_proxy ()
#9 0x0000005555c6e438 in start_thread () from /lib64/libpthread.so.0
#10 0x0000005555feed6c in __thread_start () from /lib64/libc.so.6
Backtrace stopped: frame did not save the PC
所以似乎这个run()函数指定它不会使用“throw()”规范抛出任何异常,引发异常(来自第4帧).根据有关__cxa_call_unexpected()的各种引用,stacktrace描述了在具有“throw()”规范的函数中引发异常时编译器要中止的典型行为.
我对这个问题的分析是对的吗?
为了测试,我在这个方法中添加了一个try catch,并打印了异常消息.现在这个过程没有核心.异常消息与工作线程捕获的异常消息相同.
我的问题是,这个线程如何访问另一个捕获的异常?他们是否共享一些与异常处理相关的数据结构?
请详细说明一下.真是令人费解..
注意: – 根据stacktrace,调用run()后立即引发call_unexpected.这加强了我对某种异常堆栈或数据共享的怀疑.但没有找到任何对此行为的引用.