У меня возникает странная ошибка при вызове функции insert в векторе пользовательских типов (которые в основном представляют собой узлы графа). Ниже приводится код, который генерирует ошибку сегм:Seg fault on std :: vector.insert
69 for (int i = 0; i < size; i++) {
70 PDTNode * node = arguments[i]->getNode();
71 //addChild(node);
72 children.insert(it, node); // children is vector <PDTNode*>
73 it++;
74 node->addParent(this);
75 }
Я перепроверить все входы и все в порядке, а не NULL. Ниже GDB трассировки стека, что я получил по вине SEG:
#0 0x00007ffff4793202 in ??() from /lib/libc.so.6
#1 0x00007ffff479163a in memmove() from /lib/libc.so.6
#2 0x00000000004289f1 in std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m<PDTNode*> (__first=0x100bd60, __last=0x10053c8,
__result=0x1001840) at /usr/include/c++/4.4/bits/stl_algobase.h:378
#3 0x00000000004289ab in std::__copy_move_a<false, PDTNode**, PDTNode**> (__first=0x100bd60, __last=0x10053c8, __result=0x1001840)
at /usr/include/c++/4.4/bits/stl_algobase.h:397
#4 0x0000000000428973 in std::__copy_move_a2<false, PDTNode**, PDTNode**> (__first=0x100bd60, __last=0x10053c8, __result=0x1001840)
at /usr/include/c++/4.4/bits/stl_algobase.h:436
#5 0x000000000042891d in std::copy<PDTNode**, PDTNode**> (__first=0x100bd60, __last=0x10053c8, __result=0x1001840)
at /usr/include/c++/4.4/bits/stl_algobase.h:468
#6 0x00000000004288dc in std::__uninitialized_copy<true>::uninitialized_copy<PDTNode**, PDTNode**> (__first=0x100bd60, __last=0x10053c8, __result=0x1001840)
at /usr/include/c++/4.4/bits/stl_uninitialized.h:93
#7 0x0000000000428847 in std::uninitialized_copy<PDTNode**, PDTNode**> (__first=0x100bd60, __last=0x10053c8, __result=0x1001840)
at /usr/include/c++/4.4/bits/stl_uninitialized.h:117
#8 0x00000000004287b8 in std::__uninitialized_copy_a<PDTNode**, PDTNode**, PDTNode*> (__first=0x100bd60, __last=0x10053c8, __result=0x1001840)
at /usr/include/c++/4.4/bits/stl_uninitialized.h:257
#9 0x0000000000428684 in std::__uninitialized_move_a<PDTNode**, PDTNode**, std::allocator<PDTNode*> > (__first=0x100bd60, __last=0x10053c8,
__result=0x1001840, __alloc=...) at /usr/include/c++/4.4/bits/stl_uninitialized.h:267
#10 0x000000000042812e in std::vector<PDTNode*, std::allocator<PDTNode*> >::_M_insert_aux (this=0x1002810, __position=..., [email protected])
at /usr/include/c++/4.4/bits/vector.tcc:338
#11 0x000000000043c46d in std::vector<PDTNode*, std::allocator<PDTNode*> >::insert (this=0x1002810, __position=..., [email protected])
at /usr/include/c++/4.4/bits/vector.tcc:126
#12 0x00000000004d3ea9 in PDTFunctionDec::setArguments (this=0x10027e0, arguments=...) at PDTFunction.cpp:72
Любая помощь высоко ценится.
Спасибо
достаточно не код, чтобы сказать. Мой ленивый подход состоял бы в том, чтобы запустить его под «valgrind», который обычно указывает на вещи быстро. – smparkes