This question already has an answer here:

I see a lot of solutions to resolving the problem exemplified by

Illegal instruction (core dumped)

But, I'm wondering what exactly that means? What generates that error, and what's the root cause of it? Is that the CPU getting someone it believes is an instruction but can't decode? What happens under the hood to generate that error?

From dmesg, I see

[429572.598803] traps: test[4054] trap invalid opcode ip:400066 sp:ffac8cc0 error:0 in test[400000+1000]
[429758.598292] traps: test[4401] trap invalid opcode ip:400066 sp:ffa3f990 error:0 in test[400000+1000]
[430066.170626] traps: test[4854] trap invalid opcode ip:400066 sp:ff8ab000 error:0 in test[400000+1000]
[430439.855002] traps: test[5212] trap invalid opcode ip:8048071 sp:ffce2fa0 error:0 in test[8048000+1000]

marked as duplicate by Kusalananda, dirkt, user88036, RalfFriedl, G-Man Sep 24 '18 at 21:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Yes, the CPU generates an interrupt/trap/whatever the architecture calls it, and then a signal is raised as explained in the duplicate link. – dirkt Sep 24 '18 at 10:23
  • Is it possible for you to run this test program under a debugger? There are several possible causes for SIGILL (a totally random illegal instruction due to memory errors, a ud2 instruction intentionally inserted by the compiler, or a library function intentionally posting that signal), and it may be useful to see the actual instruction and stack trace that caused it. – Mark Plotnick Sep 24 '18 at 11:32

For the x86. This on-screen error seems to be a result of SIGILL being sent by the kernel, which is a "CPU Trap" defined in kernel/traps.c to catch X86_TRAP_UD. It's one in a class of a few others that are raised directly from the CPU that include,

X86_TRAP_DE,        divide_error
X86_TRAP_NMI,       nmi
X86_TRAP_BR,        bounds
X86_TRAP_UD,        invalid_op
X86_TRAP_NM,        device_not_available
X86_TRAP_OLD_MF,    coprocessor_segment_overrun
X86_TRAP_TS,        invalid_TSS
X86_TRAP_NP,        segment_not_present
X86_TRAP_SS,        stack_segment
X86_TRAP_GP,        general_protection
X86_TRAP_SPURIOUS,  spurious_interrupt_bug
X86_TRAP_MF,        coprocessor_error
X86_TRAP_AC,        alignment_check
X86_TRAP_XF,        simd_coprocessor_error

For amusement, you can see a list of programs demonstrating this with Golf here

  • 1
    @Kusalananda updated to clarify. – Evan Carroll Sep 24 '18 at 10:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.