Infobox Computing signal
description = Illegal instruction
action = Abnormal termination of the process
ILL_ILLOPC | illegal opcode
ILL_ILLOPN | illegal operand
ILL_ADR | illegal addressing mode
ILL_ILLTRP | illegal trap
ILL_PRVOPC | privileged opcode
ILL_PRVREG | privileged register
ILL_COPROC | coprocessor error
ILL_BADSTK | internal stack error
SIGILL is the signal sent to computer programs that attempt to execute malformed, unknown, or privileged instructions on
POSIX-compliant platforms. The symbolic constant for SIGILL is defined in the
header file. Symbolic signal names are used because signal numbers can vary across platforms.
"SIG" is a common
prefixfor signal names; "ILL" is an abbreviationfor "illegal instruction".
There are many possible reasons for receiving a SIGILL. A common mistake involves accidentally overwriting stack data with a
return addressthat points to datanot meant to be executed or trying to execute a function pointerthat is not properly initialized. Other problems might involve compiler( toolchain) bugs, filesystemcorruption or attempting to execute instructionsthat require special privileges.
Many platforms implement new instructions or provide additional registers on subsequent hardware revisions, so applications compiled for more recent hardware may generate "illegal instructions" when run on older hardware that does not recognise the new
opcodes. An example might be attempting to use MMX instructions on an Intel 80486processor, which didn't support the feature.
SIGILL can also be generated by users with the appropriate permissions, using the
SIGILL can be handled. That is,
programmerscan specify the action they would like to occur upon receiving a SIGILL, such as execute a subroutine, ignore the event, or restore the default behaviour. BIND8 used this mechanism to write server statistics to an external file.
Note that under certain circumstances, attempting to ignore SIGILL can result in
Sometimes bad call linkage will also cause SIGILL. In C++, passing a non-POD data type into a
variadic functionsuch as printfwill cause undefined behavior; in GCCthis means deliberately placing an illegal instruction at that point in the assembler.
Here is an example of an
ANSI Cprogram that attempts to execute an illegal instruction on platforms where 0xFFFFFFFF is not a valid opcode.
Compiling and running it on
IA-32with Linuxproduces the following:
$ gcc -o sigill sigill.c $ ./sigill Illegal instruction (core dumped)
On more recent processors and Linux versions, the program above may not receive a SIGILL because of the
NX bitfeature, that allows the Linux kernel to make the memory pages on the program stack non-executable by default. On those cases, the program will receive the SIGSEGVsignal.
backtracefrom gdbshows that the program crashed within the
mainfunction when the program tried to execute an instruction at address 0xBFFFEDE4:
Program received signal SIGILL, Illegal instruction. 0xbfffede4 in ?? () (gdb) bt #0 0xbfffede4 in ?? () #1 0x0804837f in main () (gdb) x/i $pc 0xbfffede4: (bad)
Note "(bad)", indicating that the
debuggerdoes not recognize the opcode at that address. The mnemonicrepresenting the instruction would normally be displayed there.
Compare the output from SIGILL with that of a segmentation fault and a SIGFPE signal.
Pentium F0 bug
Wikimedia Foundation. 2010.