当我手动调用std :: vector上的函数时,为什么gdb会获得SEGV?

时间:2015-02-25 18:11:41

标签: c++ gdb stdvector sigsegv

移动到Centos 5(从4开始)后,当我尝试在std :: vector上调用成员函数时,我看到gdb崩溃了:

(gdb) p actionQueue->size()

Program received signal SIGSEGV, Segmentation fault.
0x081d881e in indexedActionQueue::size (this=0xbfbd0050) at actionList.h:52
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(indexedActionQueue::size() const) will be abandoned.
(gdb) p actionQueue->_actionQueue
$1 = std::vector of length 7, capacity 7 = {
   [...]
    }
(gdb) p actionQueue->_actionQueue.empty()

Program received signal SIGSEGV, Segmentation fault.
0x08158ea3 in std::vector<CAction, std::allocator<CAction> >::empty (this=0xa514788) at /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/stl_vector.h:735
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(std::vector<CAction, std::allocator<CAction> >::empty() const) will be abandoned.
(gdb) p actionQueue->_actionQueue.begin()

Program received signal SIGSEGV, Segmentation fault.
0x08188ec6 in std::vector<CAction, std::allocator<CAction> >::begin (this=0xa514788) at /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/stl_vector.h:539
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(std::vector<CAction, std::allocator<CAction> >::begin()) will be abandoned.

我尝试将gdb更新为v7.9但是我得到了相同的结果。我正在使用scl enable devtoolset-2使用gcc v4.8.2进行构建。如果我在gdb中打印std::vector,它看起来是正确的。

如果我将获得SEGV的方法直接放入C ++应用程序中,它们在没有SEGV的情况下运行,但在gdb中手动运行它们会得到一个SEGV。

如何让gdb允许这些调用工作?

0 个答案:

没有答案