(gdb) bt
#0 0x000000368d275fd5 in malloc_consolidate () from /lib64/libc.so.6
#1 0x000000368d279c28 in _int_malloc () from /lib64/libc.so.6
#2 0x000000368d27ab1c in malloc () from /lib64/libc.so.6
#3 0x000000368debd09d in operator new(unsigned long) () from /usr/lib64/libstdc++.so.6
#4 0x000000000040fbcd in __gnu_cxx::new_allocator<unsigned char>::allocate (this=0x7ffc7e0136d8, __n=4096)
at /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/new_allocator.h:89
#5 0x000000000040f575 in std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_M_allocate (this=0x7ffc7e0136d8, __n=4096)
at /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_vector.h:140
#6 0x000000000040f186 in std::vector<unsigned char, std::allocator<unsigned char> >::_M_allocate_and_copy<unsigned char*> (this=0x7ffc7e0136d8,
__n=4096, __first=0x0, __last=0x0) at /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_vector.h:963
#7 0x000000000040e7c7 in std::vector<unsigned char, std::allocator<unsigned char> >::reserve (this=0x7ffc7e0136d8, __n=4096)
at /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/vector.tcc:74
#8 0x00000000004cc616 in ByteBuffer::ByteBuffer (this=0x7ffc7e0136c0) at ../../../../src/shared/./util/ByteBuffer.h:19
#9 0x00000000004cb947 in ReplayMgr::SaveToDB (this=0x23a40d0, pBase=0x57a1160) at ./Replay/ReplayMgr.cpp:95
百度了下可能是某個地方數組越界把不該寫的記憶體寫壞了
請問有沒有什麼好的辦法檢查數組越界的地方具體在哪裡?
女神的闺蜜爱上我2017-06-07 09:26:17
你用 bt 看堆疊有什麼用...
既然程式碼是你寫的,仔細檢查一些文法,這是最直接的方法。下幾個關鍵的斷點,一步一步執行一下,很快就能發現問題所在。
另外,dump法也是解決類似錯誤的有效方法。