是什么导致信号“SIGILL”?
我正在使用 NDK 和 GCC 将一些 C++ 代码移植到 Android。代码基本跑起来了。有一次,在 Eclipse 中调试时,调用
Dabbler::Android::Factory* pFactory = new Dabbler::Android::Factory;
会导致此错误:
Thread [1] (Suspended: Signal 'SIGILL' received. Description: Illegal instruction.)
1 <symbol is not available> 0x812feb44
这是什么意思?编译器是否由于某种原因生成了非法代码?我在构造函数中有一个断点(它什么也不做),但它没有被命中。我已经完成了全面重建。
我可能做错了什么导致这个问题?
I'm porting some C++ code to Android using NDK and GCC. The code basically runs. At one point, when debugging in Eclipse, the call
Dabbler::Android::Factory* pFactory = new Dabbler::Android::Factory;
causes this error:
Thread [1] (Suspended: Signal 'SIGILL' received. Description: Illegal instruction.)
1 <symbol is not available> 0x812feb44
What does that mean? Has the compiler generated illegal code for some reason? I have a breakpoint in the constructor (which does nothing), and it's not hit. I have already done a full rebuild.
What could I be doing wrong to cause this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
确保所有具有非 void 返回类型的函数都有
return
语句。虽然某些编译器会自动提供默认返回值,但其他编译器会在运行时尝试让函数不带返回值时发送 SIGILL 或 SIGTRAP。
Make sure that all functions with non-void return type have a
return
statement.While some compilers automatically provide a default return value, others will send a SIGILL or SIGTRAP at runtime when trying to leave a function without a return value.
这意味着 CPU 试图执行它不理解的指令。我猜这可能是由于损坏引起的,或者可能是针对错误的体系结构进行编译的(在这种情况下,我会认为操作系统会拒绝运行可执行文件)。不完全确定根本问题是什么。
It means the CPU attempted to execute an instruction it didn't understand. This could be caused by corruption I guess, or maybe it's been compiled for the wrong architecture (in which case I would have thought the O/S would refuse to run the executable). Not entirely sure what the root issue is.
它可能是一些未初始化的函数指针,特别是如果您的内存已损坏(那么指向无效对象的 C++ 错误指针的虚假 vtable 可能会导致这种情况)。
BTW
gdb
观察点和跟踪点以及 valgrind 可能对调试此类问题很有用(如果可用)。或者一些地址清理工具。It could be some un-initialized function pointer, in particular if you have corrupted memory (then the bogus vtable of C++ bad pointers to invalid objects might give that).
BTW
gdb
watchpoints & tracepoints, and also valgrind might be useful (if available) to debug such issues. Or some address sanitizer.LeetCode 的在线编译器和开发环境对于不生成相同错误的错误会生成
SIGILL
错误在我的桌面 IDE 中。例如,具有越界索引的数组访问:
LeetCode 的编译器仅显示错误:
但相同的代码会导致 错误:
只有在完整的 Xcode 项目编译和运行中才会报告实际错误:
LeetCode's online compiler and dev environment generates
SIGILL
errors for mistakes that do not generate the same error in my desktop IDE.For example, array access with an out-of-bounds index:
LeetCode's compiler shows only the error:
in a local Xcode playground this same code instead results in the error:
Only in a full Xcode project compilation and run does it report the actual error: