Protection violation

from Wikipedia, the free encyclopedia

In computers , a occurs protection fault (from English segmentation fault or segmentation violation short segfault ) or access violation (engl. Access violation ) when a computer program attempts to access a resource (particularly to memory), which is protected from such access or should not be reachable. Here, the operating system kernel sends a signal to the process that triggered the mistake, which normally results in its termination. The memory protection of modern operating systems and the memory protection units of the microcontrollers are precautions for other processes and the operating system.

Not every bad memory access triggers the protection fault exception. One and the same program error can, depending on the general system state and thus more or less randomly, trigger a crash due to a protection violation, lead to arithmetically incorrect calculation results or other undesirable system behavior, or even remain completely without consequences.

The English term segmentation fault comes from a time when memory areas were protected from unauthorized access by segmentation . Other protection mechanisms are used today, particularly paging ; the term segmentation fault has remained unchanged. The segmentation fault is not to be confused with the page fault , which merely interrupts the program until the missing page has been loaded from secondary memory into main memory.

Under Unix , segmentation violation triggers the exception condition SIGSEGV (exception decimal 11 , hexadecimal B , 0x0B ). With IA-32 or x86 processors , a memory access violation is referred to as a general protection violation (exception: decimal 13 , hexadecimal D , 0x0D ), which is triggered by an interrupt .

Examples

The massive occurrence of protection violations indicates conceptual weaknesses of an operating system, a driver , a programming language or a program. A wide audience will remember the error message “General protection fault in”, followed by a hexadecimal address with which programs often crashed under early Microsoft Windows versions (the so-called blue screen of death ).

Defective main memory or other defective hardware can also be a reason for the frequent occurrence of protection violations . Addresses that are unintentional due to hardware errors are addressed (e.g. it is sufficient to change a single bit of an address). Also overclocking or faulty programmed device driver can trigger such errors without the need for a defect is necessary.

Example of a C program that almost always triggers a protection violation on every system:

int main(void)
{
    /* Initialisiere den Zeiger ptr mit der Speicheradresse 0.
       Das ist erlaubt, obwohl diese Adresse zu einem geschützten
       Bereich gehört. */
    int* ptr = (int*) 0;

    /* Nun versuche, irgendeinen Wert (z.B. 42) in die Adresse 0
       zu schreiben. Das wird eine Schutzverletzung auslösen. */
    *ptr = 42;

    return 0;
}

Individual evidence

  1. Source code of the UNIX header file signal.h .  ( Page no longer available , search in web archivesInfo: The link was automatically marked as defective. Please check the link according to the instructions and then remove this notice. Sourceware.org; Retrieved September 14, 2010.@1@ 2Template: Dead Link / sourceware.org  
  2. Klaus Wüst: Microprocessor Technology: Fundamentals, architectures and programming of microprocessors, microcontrollers and signal processors. 3rd edition, Vieweg + Teubner Verlag, Wiesbaden 2009, ISBN 978-3-8348-0461-7 , pp. 174-179.