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?
It works now. For anyone else struggling with Android/NDK/GCC/Eclipse, here's how I solved it:
- Bury a dead cat at midnight when full moon
- Restart the Android device emulator
Haven't verified if both steps are really necessary, and if not, which one is redundant.
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.
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.
If you are migrating code from gcc to clang and start getting SIGILL or SIGTRAP in the last statement of some function, then make sure the function has a return
statement if it has been declared with non-void return type.
来源:https://stackoverflow.com/questions/7901867/what-causes-signal-sigill