C++ catch块未捕获该异常
是的,老编译器GCC4.0.1让我很难过:C++ catch块未捕获该异常,c++,exception,gdb,C++,Exception,Gdb,是的,老编译器GCC4.0.1让我很难过: typedef std::tr1::shared_ptr<xmlpp::DomParser> PtrDomParser; 这是我的代码: try{ //here I'm using xml++ library to handle xml PtrDomParser parser = cdata_file_to_parser(responseFilePath); xmlpp::Document *response =
typedef std::tr1::shared_ptr<xmlpp::DomParser> PtrDomParser;
这是我的代码:
try{
//here I'm using xml++ library to handle xml
PtrDomParser parser = cdata_file_to_parser(responseFilePath);
xmlpp::Document *response = parser->get_document();
xmlpp::NodeSet nodeSet;
xmlpp::Node *node;
xmlpp::Element *root;
typedef xmlpp::NodeSet::iterator It;
root = response->get_root_node();
//... some code ...
throw Exception();
}
catch (const Exception &exc){
std::cout << "Exception is captured!" << std::endl;
}
catch (...){
std::cout << "Something else is captured!" << std::endl;
}
事实如下:
一,。并非每次流达到抛出异常时都会发生这种情况;,大多数情况下,捕获异常
二,。有时,当流到达时,100%抛出异常;-未捕获异常,程序冻结,当我尝试使用gdb连接到程序并键入where-时,我看到:
0xb7fd8430在内核vsyscall中
0xb7d9bece在/lib/i686/libpthread.so.0的_lll_mutex_lock-wait中
0xb7d98500位于/lib/i686/libpthread.so.0的互斥锁中
0xbfbefab8英寸??
0x00000000英寸??
0x00000000英寸??
三,。GCC4.0.1,GDB6.3,我还不能更新它们
五,。xml++库
六,。嗯,程序使用了很多线程,我甚至不知道它们是如何工作的,以及它们在我的工作中完成了什么,但是我知道,我不使用任何共享变量或其他可能导致这种行为的smth
五,。嗯,我认为xmlpp析构函数有问题,但我不知道它是什么,也不知道如何跟踪它或如何找出它
更新:
我没有找到问题所在,但有时我会遇到另一个类似于第一个问题的问题
当调用共享的\u ptr析构函数时,该问题会在另一个函数结束后立即发生
同样,我附加到流程中,输入where和gdb说:
========================
内核vsyscall中的0 0xb7fd8430
1 0xb7d9bece在/lib/i686/libpthread.so.0的_lll_mutex_lock-wait中
来自/lib/i686/libpthread.so.0的2个0xb7d98500 in _L_mutex_lock_71
…不知道这是什么,我只看到。。在
10。。在线程互斥锁中
11。。在线程互斥锁中
12。。在std::tr1::_Sp_counted_base::release中
13。。在~u计数中
14。。在~shared\u ptr中
=======================
好像共享的ptr坏了?
此外,我惊讶地发现,当我使用std::tr1::shared_ptr时,使用了boost_shared_ptr.h。gdb说,wtf 闻起来像是死锁?是的,但可能是库中存在问题,我不知道如何跟踪iTunes线程在gdb中应用所有回溯跟踪,并检查哪些其他线程等待锁定。也许你会发现哪个锁是罪魁祸首。此外,如果可以的话,您可以尝试helgrind。尝试减少再现错误所需的代码量。然后再进一步减少。这样你可能会发现你的错误。如果您没有,请将最简单的示例发送给库维护人员进行检查,因为如果它是xml++库中的一个bug,他们会对一个精确的bug报告感到高兴。谢谢大家,我尝试使用thread apply all backtrace,现在我看到了很多信息,这可能会有所帮助,我现在需要一段时间来研究它。如果它是一个xml++库错误,那么我将把它发送给维护人员