Causes of General Protection Faults

Last reviewed: February 11, 1998
Article ID: Q82710
********************************************************************
     BETA INFORMATION  BETA INFORMATION  BETA INFORMATION  BETA

     This article discusses a Beta release of a Microsoft
     product. The information in this article is provided as-is
     and is subject to change without notice.

     No formal product support is available from Microsoft for
     this Beta product. For information about obtaining support
     for a Beta release, please see the documentation included
     with the Beta product files, or check the Web location
     from which you downloaded the release.

     BETA INFORMATION  BETA INFORMATION  BETA INFORMATION  BETA
********************************************************************

The information in this article applies to:

  • Microsoft Windows operating system versions 3.1, 3.11
  • 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 6. 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
Keywords : wfwg win31 winmem win98
Version : WINDOWS:3.1,3.11,98
Platform : WINDOWS
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.