General protection fault Exceptions in Linux/IA32 Systems

Computer Systems A Programmer's Perspective Second Edition

Exception number Description Exception class
0 Divide error Fault
13 General protection fault Fault
14 Page fault Fault
18 Machine check Abort
32–127 OS-defined exceptions Interrupt or trap
128 (0x80) System call Trap
129–255 OS-defined exceptions Interrupt or trap
Figure 8.9 Examples of exceptions in IA32 systems.

Linux/IA32 Faults and Aborts
Divide error. A divide error (exception 0) occurs when an application attempts to
divide by zero, or when the result of a divide instruction is too big for the destina-
tion operand. Unix does not attempt to recover from divide errors, opting instead
to abort the program. Linux shells typically report divide errors as “Floating ex-
ceptions.”
General protection fault. The infamous general protection fault (exception 13)
occurs for many reasons, usually because a program references an undefined area
of virtual memory, or because the program attempts to write to a read-only text
segment. Linux does not attempt to recover from this fault. Linux shells typically
report general protection faults as “Segmentation faults.”
Page fault. A page fault (exception 14) is an example of an exception where
the faulting instruction is restarted. The handler maps the appropriate page of
physical memory on disk into a page of virtual memory, and then restarts the
faulting instruction. We will see how page faults work in detail in Chapter 9.
Machine check. A machine check (exception 18) occurs as a result of a fatal
hardware error that is detected during the execution of the faulting instruction.
Machine check handlers never return control to the application program.

上一篇:JS代码的window.location属性详解


下一篇:Android组件化和插件化开发