c++ - 程序接收信号 SIGILL,非法指令

标签 c++ linux g++ shared-libraries runtime-error

我正在使用 Linux x86_64 机器来构建我的程序。 我已将共享库链接到可执行文件。在我的项目中,我正在调用一个声明 vector<string> 的函数函数内部。当该函数被调用时,我的程序被杀死。 下面是通过GDB调试时得到的输出。

Program received signal SIGILL, Illegal instruction.
0x00002aaaac4d2be7 in OC_Catalog_c::File_ToText (this=0x611aa0) at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:87
87              : _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
(gdb) bt
0  0x00002aaaac4d2be7 in OC_Catalog_c::File_ToText (this=0x611aa0) at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:87

这是我的共享库编译的问题吗? 把我的头撞得够呛。请帮忙。

-查克斯

为您的查询添加更多信息: 是的,我调用 File_ToText 的函数是 OC_Catalog_c 类中的虚函数。 其他类的成员变量具有类 OC_Catalog_c 的对象,该对象也具有虚函数 File_ToText。使用该对象,我正在从虚函数 File_ToText 调用 OC_Catlog_c 的 File_ToText 函数。 我将显示一个代码片段:

class Oc_Catalog_c  
{
    virtual vector<string>  File_ToText             (void) const; 
}

class B
{
    const OC_Catalog_c*         m_pCatalog;
    virtual vector<string>  File_ToText             (void) const; 
}

vector<string> B::File_ToText( void ) const
{
    vector<string> a_SubData;
    a_SubData = m_pCatalog->File_ToText();
}

最佳答案

感谢大家的帮助。 我终于找出了导致此错误的问题。
调试更多并跟踪指令我发现程序在 ud2a 指令处失败。
我忽略了一个警告“警告:不能通过'...'传递非POD类型'struct sqlrw_request_cb'的对象;调用将在运行时中止”。
解决这些警告解决了我与 SIGILL 相关的问题。
此链接的更多说明: ud2a instruction causing SIGILL

关于c++ - 程序接收信号 SIGILL,非法指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18410344/

相关文章:

c++ - 在这个失败的 C++ 类实例化中,我忽略了什么明显的事情?

使用 fork() 进行 C 系统编程

c++ - CMake 传递的变量编译器无法编译简单程序

c++ - 对 `GdiplusStartup@12' 的 undefined reference

c++ - 附加到 Qt Creator 中正在运行的进程后如何查看控制台输出?

c++ - 单元测试 : checks that some expressions shouldn't be compiled

c++ - 如何在函数指针中包含参数?

linux - 如何在 Linux 中打开默认的文本编辑器?

c++ - 在 C++ 结构中显示垃圾值

c++ - GCC 警告已声明但 undefined variable