Reputation: 33
On linux platform, my application program got core dump occasionally due to a signal 4. And I find that signal 4 means Illegal Instruction. So I have one question: How to got Illegal Instruction and what might cause signal 4 core dump.
Upvotes: 3
Views: 26367
Reputation: 1
A more frequent possibility is the usage of an uninitialized or corrupted function pointer (or vtable in C++).
If your C code calls a corrupted function pointer, that address may lead anywhere, including inside some data, which, when the processor tries to execute it, will give you a SIGILL signal.
It could also happen with label as values and computed goto *x;
(a commonly used GCC extension to C), if jumping to a bad address.
It could even happen if you corrupt your call stack badly enough to overwrite the return address.
Very probably, using your gdb
debugger (or perhaps also valgrind
) should help you.
My advice is to always initialize pointers (e.g. to NULL), including function pointers. IIRC, if you call the NULL function pointer, you get a SIGSEGV.
Upvotes: 6
Reputation: 104080
You might have compiled code for a different processor model or you might have installed code intended for a different processor model. There are a huge variety of impressive SIMD instructions in modern CPUs to speed up compute-intensive tasks (MMX, SSE, SSE2, SSSE3, SSE4.1, SSE4.2, 3dNOW! (and its derivatives)), instructions for faster system calls, instructions for faster lock handling (popcnt), instructions for computing rounds of AES, etc.
Perhaps your code was compiled assuming some of these instructions were available, but your CPU does not support them.
Another possibility is bad memory or corrupted data on your hard drive. memtest86 can help you find bad memory, and you can use debsums
or rpm -qV
or similar package manager commands to check if your programs still match the checksums they had when they were first installed.
Upvotes: 6