Linux 程序接收信号SIGILL,非法指令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18410344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:38:57  来源:igfitidea点击:

Program received signal SIGILL, Illegal instruction

c++linuxg++shared-librariesruntime-error

提问by Chaks

I am using Linux x86_64 machine to build my program. I have linked a shared library to an executable. In my project I am calling a function which has declared vector<string>inside the function. My program gets killed when that function gets called. When debugging through GDB below is the output I get.

我正在使用 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

Is this issue of compilation of my shared library?? Banged my head enough on it. Please help.

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

-Chaks

-查克斯

Adding more info for your queries: Yes,function that i am calling File_ToText is a virtual function in class OC_Catalog_c. A member variable of other class has object of class OC_Catalog_c which also have virtual function File_ToText.Using that object I am calling File_ToText function of OC_Catlog_c from virtual function File_ToText. I will show a code snippet:

为您的查询添加更多信息:是的,我调用 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();
}

回答by Chaks

Thank you guys for all your help. I finally figured out the problem that was causing this error.
Debugging more and tracing the instruction I found that program was failing at ud2a instruction.
I was ignoring one warning "warning: cannot pass objects of non-POD type 'struct sqlrw_request_cb' through '...'; call will abort at runtime".
Resolving these warnings fixed my problem related to SIGILL.
More explanation on this link: ud2a instruction causing SIGILL

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