使用bad_alloc异常终止,但堆栈跟踪中没有“new”

时间:2011-08-24 18:10:10

标签: c++ linux exception

C ++程序正在抛出这个:

在抛出'St9bad_alloc'的实例后调用终止what():std :: bad_alloc

它似乎是从new抛出的,但堆栈跟踪没有显示对new的任何调用:

#0  0x0000003174a330c5 in raise () from /lib64/libc.so.6
#1  0x0000003174a34a76 in abort () from /lib64/libc.so.6
#2  0x00007f93b1b7b0b4 in __gnu_cxx::__verbose_terminate_handler ()
at ../../../../gcc-4.3.4/libstdc++-v3/libsupc++/vterminate.cc:98
#3  0x00007f93b1b794f6 in __cxxabiv1::__terminate (handler=0x522b)
at ../../../../gcc-4.3.4/libstdc++-v3/libsupc++/eh_terminate.cc:43
#4  0x00007f93b1b79523 in std::terminate ()
at ../../../../gcc-4.3.4/libstdc++-v3/libsupc++/eh_terminate.cc:53
#5  0x00007f93b1b79536 in __cxxabiv1::__unexpected (handler=0x522b)
at ../../../../gcc-4.3.4/libstdc++-v3/libsupc++/eh_terminate.cc:59
#6  0x00007f93b1b78ec8 in __cxxabiv1::__cxa_call_unexpected (exc_obj_in=0x7f93b1dae770)
at ../../../../gcc-4.3.4/libstdc++-v3/libsupc++/eh_personality.cc:750
#7  0x00007f93b2c356e0 in network::HttpLoader::doLoad (this=0x7f938801ef20) at loaders/HttpLoader.cxx:1071
#8  0x00007f93b2c70971 in network::Loader::load (this=0x522b) at Loader.cxx:899
#9  0x00007f93b2c74a15 in network::Loader::load2 (this=0x522b) at Loader.cxx:925
#10 0x00007f93b2c7b13a in network::LoaderThread::run() ()
#11 0x00007f93b1e60be4 in threads::Thread_startWorker (thr=0x7f938801e460) at Threads.cxx:479
#12 0x00007f93b1e60ead in threads::ThreadPool::run (this=0x1140478, thr=0x7f938801eeb0) at Threads.cxx:727
#13 0x00007f93b1e608e8 in threads::__Thread_startWorker (param=<value optimized out>) at Threads.cxx:520
#14 0x0000003175206ccb in start_thread () from /lib64/libpthread.so.0
#15 0x0000003174ae0c2d in clone () from /lib64/libc.so.6

在doLoad()的开头添加了调试语句,但它永远不会到达那一点。

难倒!

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

new调用可能不在堆栈中,因为它已在应用程序终止时解除。我试图在异常抛出时设置一个断点(例如,在gdb下使用catch throw) - 此时你将看到异常的原因叠加。

答案 1 :(得分:0)

Maby由于优化而内联new来电。尝试禁用优化,至少在loaders/HttpLoader.cxx