Causes of General Protection Faults
ID: Q82710
|
The information in this article applies to:
-
Microsoft Windows operating system versions 3.1, 3.11
-
Microsoft Windows 95
-
Microsoft Windows 98
SUMMARY
Intel 80286, 80386, and 80486 CPUs can detect when a program does
something wrong. The most common problems are stack faults, invalid
instructions, divide errors (divide by zero), and general protection
faults. These generally indicate nonstandard code in an application.
MORE INFORMATION
The following faults can occur in a Windows application, in Windows
itself, or in a Windows device driver (for example, a video display
driver).
Stack Fault (Interrupt 12)
Reasons for a stack fault are:
- An instruction tries to access memory beyond the limits of the
Stack segment (POP, PUSH, ENTER, LEAVE, or a stack relative access:
MOV AX, [BP+6]).
- Loading SS with a selector marked not present, but otherwise valid
(shouldn't happen under Windows).
Stack faults are always fatal to the current application in Windows.
Invalid Instruction (Interrupt 6)
The CPU detects most invalid instructions, and generates an Interrupt
- This is always fatal to the application. This should never happen,
and is usually caused by executing data instead of code.
Divide Error (Interrupt 0)
This is caused when the destination register cannot hold the result of
a divide operation. It could be divide by zero, or divide overflow.
General Protection Fault (Interrupt 13)
All protection violations that do not cause another exception cause a
general protection exception. This includes, but is not limited to:
- Exceeding the segment limit when using the CS, DS, ES, FS, GS
segments. This is a very common bug in programs, usually caused by
miscalculating how much memory is required in an allocation.
- Transferring execution to a segment that is not executable
(for example, jumping to a location that contains garbage).
- Writing to a read-only or a code segment.
- Loading a bad value into a segment register.
- Using a NULL pointer. A value of 0 is defined as a null pointer. In
protected mode, it is always invalid to use a segment register that
contains 0.
Additional query words:
3.10 gpfault 3.0a \* TestWin4
Keywords : win31 win95 winmem win98 wfwg
Version : WINDOWS:3.1,3.11,98
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: January 13, 1999