Unrecoverable Application Error
   HOME

TheInfoList



OR:

A general protection fault (GPF) in the
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
instruction set architecture In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, ...
s (ISAs) is a fault (a type of
interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
) initiated by ISA-defined protection mechanisms in response to an access violation caused by some running code, either in the
kernel Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learnin ...
or a user program. The mechanism is first described in Intel manuals and datasheets for the
Intel 80286 The Intel 80286 (also marketed as the iAPX 286 and often called Intel 286) is a 16-bit microprocessor that was introduced on February 1, 1982. It was the first 8086-based CPU with separate, non- multiplexed address and data buses and also the f ...
CPU, which was introduced in 1983; it is also described in section 9.8.13 in the
Intel 80386 The Intel 386, originally released as the 80386 and later renamed i386, is the third-generation x86 architecture microprocessor from Intel. It was the first 32-bit computing, 32-bit processor in the line, making it a significant evolution in ...
programmer's reference manual from 1986. A general protection fault is implemented as an interrupt (
vector Vector most often refers to: * Euclidean vector, a quantity with a magnitude and a direction * Disease vector, an agent that carries and transmits an infectious pathogen into another living organism Vector may also refer to: Mathematics a ...
number 13 (0Dh)). Some
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s may also classify some exceptions not related to access violations, such as illegal
opcode In computing, an opcode (abbreviated from operation code) is an enumerated value that specifies the operation to be performed. Opcodes are employed in hardware devices such as arithmetic logic units (ALUs), central processing units (CPUs), and ...
exceptions, as general protection faults, even though they have nothing to do with memory protection. If a CPU detects a protection violation, it stops executing the code and sends a GPF interrupt. In most cases, the operating system removes the failing
process A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management * Business process, activities that produce a specific s ...
from the execution queue, signals the user, and continues executing other processes. If, however, the operating system fails to catch the general protection fault, i.e. another protection violation occurs before the operating system returns from the previous GPF interrupt, the CPU signals a
double fault On the x86 architecture, a double fault exception occurs if the processor encounters a problem while trying to service a pending interrupt or exception. An example situation when a double fault would occur is when an interrupt is triggered bu ...
, stopping the operating system. If yet another failure ( triple fault) occurs, the CPU is unable to recover; since 80286, the CPU enters a special halt state called "Shutdown", which can only be exited through a
hardware reset In a computer or data transmission system, a reset clears any pending errors or events and brings a system to normal condition or an initial state, usually in a controlled manner. It is usually done in response to an error condition when it is ...
. The
IBM PC AT The IBM Personal Computer AT (model 5170, abbreviated as IBM AT or PC/AT) was released in 1984 as the fourth model in the IBM Personal Computer line, following the IBM PC/XT and its IBM Portable PC variant. It was designed around the Intel 802 ...
, the first
PC-compatible An IBM PC compatible is any personal computer that is hardware- and software-compatible with the IBM Personal Computer (IBM PC) and its subsequent models. Like the original IBM PC, an IBM PC–compatible computer uses an x86-based central pro ...
system to contain an 80286, has hardware that detects the Shutdown state and automatically resets the CPU when it occurs. All descendants of the PC AT do the same, so in a PC, a triple fault causes an immediate system reset.


Specific behavior


Microsoft Windows

In
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
, the general protection fault presents with varied language, depending on product version: In Windows 95, 98 and Me, there is an alternate error message, used mostly with Windows 3.x programs: "An error has occurred in your program. To keep working anyway, click Ignore and save your work in a new file. To quit this program, click Close. You will lose information you entered since your last save." Clicking "Close" results in one of the error messages above, depending on Windows version. "Ignore" sometimes does this too.


Unix

In
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
and other
Unices A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
, the errors are reported separately (e.g.
segmentation fault In computing, a segmentation fault (often shortened to segfault) or access violation is a Interrupt, failure condition raised by hardware with memory protection, notifying an operating system (OS) the software has attempted to access a restricted ...
for memory errors).


Memory errors

In memory errors, the faulting program accesses
memory Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembe ...
that it should not access. Examples include: * Attempting to write to a read-only portion of memory * Attempting to execute
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
s in memory which are not designated as instructions * Attempting to read as data bytes in memory which are designated as instructions * Other miscellaneous conflicts between the designation of a part of memory and its use However, many modern operating systems implement their memory access-control schemes via paging instead of segmentation, so it is often the case that invalid memory references in operating systems such as Windows are reported via
page fault In computing, a page fault is an exception that the memory management unit (MMU) raises when a process accesses a memory page without proper preparations. Accessing the page requires a mapping to be added to the process's virtual address space ...
s instead of general protection faults. Operating systems typically provide an abstraction layer (such as exception handling or signals) that hides whatever internal processor mechanism was used to raise a memory access error from a program, for the purposes of providing a standard interface for handling many different types of processor-generated error conditions. In terms of the x86 architecture, general protection faults are specific to segmentation-based protection when it comes to memory accesses. However, general protection faults are still used to report other protection violations (aside from memory access violations) when paging is used, such as the use of instructions not accessible from the
current privilege level In computer science, hierarchical protection domains, often called protection rings, are mechanisms to protect data and functionality from faults (by improving fault tolerance) and malicious behavior (by providing computer security). Computer ...
(CPL). While it is theoretically possible for an operating system to utilize both paging and segmentation, for the most part, common operating systems typically rely on paging for the bulk of their memory access control needs.


Privilege errors

There are some things on a computer which are reserved for the exclusive use of the
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
. If a program which is not part of the operating system attempts to use one of these features, it may cause a general protection fault. Additionally, there are storage locations which are reserved both for the operating system and the processor itself. As a consequence of their reservation, they are read-only and an attempt to write
data Data ( , ) are a collection of discrete or continuous values that convey information, describing the quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted for ...
to them by an unprivileged program produces an error.


Technical causes for faults

General protection faults are raised by the processor when a protected instruction is encountered which exceeds the permission level of the currently executing task, either because a user-mode program is attempting a protected instruction, or because the operating system has issued a request which would put the processor into an undefined state. General protection faults are caught and handled by modern operating systems. Generally, if the fault originated in a user-mode program, the user-mode program is terminated. If, however, the fault originated in a core system driver or the operating system itself, the operating system usually saves diagnostic information either to a file or to the screen and stops operating. It either restarts the computer or displays an error screen, such as a
Blue Screen of Death The blue screen of death (BSoD) or blue screen error, blue screen, fatal error, bugcheck, and officially known as a stop erroris a fatal system error, critical error screen displayed by the Microsoft Windows operating systems to indicate a cr ...
or
kernel panic A kernel panic (sometimes abbreviated as KP) is a safety measure taken by an operating system's Kernel (operating system), kernel upon detecting an internal Fatal system error, fatal error in which either it is unable to safely recover or con ...
.


Segment limits exceeded

Segment limits can be exceeded: * with
code segment In computing, a code segment, also known as a text segment or simply as text, is a portion of an object file or the corresponding section of the program's virtual address space that contains executable instructions. Segment The term "segment" c ...
(CS),
data segment In computing, a data segment (often denoted .data) is a portion of an object file or the corresponding address space of a program that contains initialized static variables, that is, global variables and static local variables. The size of thi ...
(DS), or ES, FS, or GS (extra segment) registers; or * accessing descriptor tables such as the
Global Descriptor Table The Global Descriptor Table (GDT) is a core part of Intel's x86 architecture that helps manage how memory is accessed and protected. Introduced with the Intel 80286 processor, it plays a key role in defining memory segments and their attributes: ...
(GDT), the
Interrupt descriptor table The interrupt descriptor table (IDT) is a data structure used by the x86 architecture to implement an interrupt vector table. The IDT is used by the processor to determine the memory addresses of the handlers to be executed on interrupts and exc ...
(IDT) and the Local Descriptor Table (LDT).


Segment permissions violated

Segment permissions can be violated by: * jumping to non-executable segments * writing to code segments, or read only segments * reading execute-only segments


Segments illegally loaded

This can occur when: * a stack segment (SS) is loaded with a segment selector for a read only, executable, null segment, or segment with descriptor privilege not matching the current privilege in CS * a code segment (CS) loaded with a segment selector for a data, system, or null segment * SS, DS, ES, FS, or GS are segments loaded with a segment selector for a system segment * SS, DS, ES, FS, or GS are segments loaded with a segment selector for an execute-only code segment * accessing memory using DS, ES, FS, or GS registers, when they contain a null selector


Switching

Faults can occur in the
task state segment The task state segment (TSS) is a structure on x86-based computers which holds information about a Task (computing), task. It is used by the operating system Kernel (operating system), kernel for task management. Specifically, the following inform ...
(TSS) structure when: * switching to a busy task during a call or jump instruction * switching to an available task during an interrupt return (IRET) instruction * using a segment selector on a switch pointing to a TSS descriptor in the LDT


Miscellaneous

Other causes of general protection faults are: * attempting to access an interrupt/exception handler from
virtual 8086 mode In the 80386 microprocessor and later, virtual 8086 mode (also called virtual real mode, V86-mode, or VM86) allows the execution of real mode applications that are incapable of running directly in protected mode while the processor is running ...
when the handler's code segment descriptor
privilege level In computer science, hierarchical protection domains, often called protection rings, are mechanisms to protect data and functionality from faults (by improving fault tolerance) and malicious behavior (by providing computer security). Computer ...
(DPL) is greater than zero * attempting to write a one into the reserved bits of CR4 * attempting to execute privileged instructions when the current privilege level (CPL) is not zero * attempting to execute a single instruction with a length greater than 15 bytes (possibly by prepending the instruction with superfluous prefixes) * writing to a reserved bit in an MSR instruction * accessing a gate containing a null segment selector * executing a software interrupt when the CPL is greater than the DPL set for the interrupt gate * the segment selector in a call, interrupt or trap gate does not point to a code segment * violating privilege rules * enabling paging whilst disabling protection * referencing the interrupt descriptor table following an interrupt or exception that is not an interrupt, trap, or a task gate * Legacy SSE: Memory operand is not 16-byte aligned.


References


Further reading

*''Intel Architecture Software Developer's Manual''–Volume 3: System Programming {{Operating System Operating system technology Computer errors