我的二进制文件崩溃了。在运行核心转储时,我发现以下内容:
#0 0x00a6a363 in memmove () from /lib/tls/libc.so.6
(gdb) frame 1
#1 0x083a108c in std::__copy_trivial<piola::piolaOrderBook*> (__first=0xb277f2c4, __last=0xb277f2bc, __result=0xb277f2c0)
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algobase.h:258
258 std::memmove(__result, __first, sizeof(_Tp) * (__last - __first));
(gdb) frame 2
#2 0x083a0ad6 in std::__copy_aux2<piola::piolaOrderBook*> (__first=0xb277f2c4, __last=0xb277f2bc, __result=0xb277f2c0)
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algobase.h:279
279 { return std::__copy_trivial(__first, __last, __result); }
(gdb) frame 3
#3 0x083a02d1 in std::__copy_ni2<piola::piolaOrderBook**, __gnu_cxx::__normal_iterator<piola::piolaOrderBook**, std::vector<piola::piolaOrderBook*, std::allocator<emapi::EmapiOrderBook*> > > > (__first=0xb277f2c4, __last=0xb277f2bc, __result=
{_M_current = 0xb277f2c0})
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algobase.h:296
296 return _OutputIterator(std::__copy_aux2(__first, __last, __result.base(),
(gdb) frame 4
#4 0x0839f1b0 in std::__copy_ni1<__gnu_cxx::__normal_iterator<piola::piolaOrderBook**, std::vector<piola::piolaOrderBook*, std::allocator<piola::piolaOrderBook*> > >, __gnu_cxx::__normal_iterator<piola::piolaOrderBook**, std::vector<piola::piolaOrderBook*, std::allocator<piola::piolaOrderBook*> > > > (__first={_M_current = 0xb277f2c4}, __last=
{_M_current = 0xb277f2bc}, __result={_M_current = 0xb277f2c0})
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algobase.h:317
317 return std::__copy_ni2(__first.base(), __last.base(),
(gdb) frame 5
#5 0x0839d676 in std::copy<__gnu_cxx::__normal_iterator<piola::piolaOrderBook**, std::vector<piola::piolaOrderBook*, std::allocator<piola::piolaOrderBook*> > >, __gnu_cxx::__normal_iterator<piola::piolaOrderBook**, std::vector<piola::piolaOrderBook*, std::allocator<piola::piolaOrderBook*> > > > (__first={_M_current = 0xb277f2c4}, __last={_M_current = 0xb277f2bc},
__result={_M_current = 0xb277f2c0})
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algobase.h:358
358 return std::__copy_ni1(__first, __last, __result, __Normal());
(gdb)
这对我来说大部分都是神秘的,但是在查找 memmove 时,似乎代码崩溃了,因为它无法处理从向量中删除(因为从向量中删除对于大型向量来说是一项非常繁重的操作)?
我对么 ?如果是,我该如何解决这个问题(当然除了修复设计)?
代码在这里:
for (orderbkIterator = vOrderBook.begin(); orderbkIterator != vOrderBook.end(); orderbkIterator++)
{
if ( (*(*orderbkIterator)->getOrderBookId()) == *(TradableInst->getOrderBookId()) )
{
long long a = (*(*orderbkIterator)->getOrderBookId());
ADDVLOG(LOG_INFO, "Removing record (%lld) from vOrderBook", a );
vOrderBook.erase(orderbkIterator);
}