b'\n_START_ARTICLE_\nPoru\xc5\xa1en\xc3\xad ochrany pam\xc4\x9bti\n_START_PARAGRAPH_\nPoru\xc5\xa1en\xc3\xad ochrany pam\xc4\x9bti (t\xc3\xa9\xc5\xbe chyba pam\xc4\x9b\xc5\xa5ov\xc3\xa9 ochrany, anglicky segmentation fault) je obecn\xc4\x9b snaha p\xc5\x99istoupit k pam\xc4\x9bti po\xc4\x8d\xc3\xadta\xc4\x8de, kterou procesor nem\xc5\xaf\xc5\xbee fyzicky adresovat. Nast\xc3\xa1v\xc3\xa1 v p\xc5\x99\xc3\xadpad\xc4\x9b, kdy hardware upozorn\xc3\xad opera\xc4\x8dn\xc3\xad syst\xc3\xa9m o nepovolen\xc3\xa9m p\xc5\x99\xc3\xadstupu k pam\xc4\x9bti. J\xc3\xa1dro opera\xc4\x8dn\xc3\xadho syst\xc3\xa9mu na tuto ud\xc3\xa1lost obvykle zareaguje n\xc3\xa1pravn\xc3\xbdm krokem. Nap\xc5\x99\xc3\xadklad ode\xc5\xa1le procesu, kter\xc3\xbd chybu vyvolal, sign\xc3\xa1l k jeho ukon\xc4\x8den\xc3\xad a v\xc3\xbdpisu pam\xc4\x9bti (core dump). Za ur\xc4\x8dit\xc3\xbdch podm\xc3\xadnek je mo\xc5\xben\xc3\xa9, aby procesy po\xc5\xbe\xc3\xa1daly o svolen\xc3\xad samy se obnovit zaveden\xc3\xadm vlastn\xc3\xad obsluhy sign\xc3\xa1lu.\n_START_SECTION_\nP\xc5\x99\xc3\xadklad chyby sb\xc4\x9brnice\n_START_PARAGRAPH_\nToto je p\xc5\x99\xc3\xadklad nezarovnan\xc3\xa9ho p\xc5\x99\xc3\xadstupu do pam\xc4\x9bti, napsan\xc3\xbd v programovac\xc3\xadm jazyce C se AT&T syntax\xc3\xad pro assembler._NEWLINE_#include <stdlib.h>int main(int argc, char **argv) {_NEWLINE_    int *iptr;_NEWLINE_    char *cptr;#if defined(__GNUC__)# if defined(__i386__)_NEWLINE_    /* Enable Alignment Checking on x86 */_NEWLINE_    __asm__("pushf\\norl $0x40000,(%esp)\\npopf");# elif defined(__x86_64__) _NEWLINE_     /* Enable Alignment Checking on x86_64 */_NEWLINE_    __asm__("pushf\\norl $0x40000,(%rsp)\\npopf");# endif#endif_NEWLINE__NEWLINE_    /* malloc() always provides aligned memory */_NEWLINE_    cptr = (char *) malloc(sizeof(int) + 1);_NEWLINE_    _NEWLINE_    /* Increment the pointer by one, making it misaligned */_NEWLINE_    iptr = (int *) ++cptr;_NEWLINE__NEWLINE_    /* Dereference it as an int pointer, causing an unaligned access */_NEWLINE_    *iptr = 42;_NEWLINE__NEWLINE_    return 0;}_NEWLINE_Kompilace a spu\xc5\xa1t\xc4\x9bn\xc3\xad p\xc5\x99\xc3\xadkladu na POSIX-kompatibiln\xc3\xadm syst\xc3\xa9mu na platform\xc4\x9b x86:_NEWLINE_$ gcc -ansi sigbus.c -o sigbus_NEWLINE_$ ./sigbus _NEWLINE_Bus error_NEWLINE_$ gdb ./sigbus_NEWLINE_(gdb) r_NEWLINE_Program received signal SIGBUS, Bus error._NEWLINE_0x080483ba in main ()_NEWLINE_(gdb) x/i $pc_NEWLINE_0x80483ba <main+54>:    mov    DWORD PTR [eax],0x2a_NEWLINE_(gdb) p/x $eax_NEWLINE_$1 = 0x804a009_NEWLINE_(gdb) p/t $eax & (sizeof(int) - 1)_NEWLINE_$2 = 1_NEWLINE_GDB debugger ukazuje, \xc5\xbee hodnota 0x2a je ulo\xc5\xbeena na adresu ulo\xc5\xbeenou v EAX registru, pou\xc5\xbeit\xc3\xadm X86 assembleru._NEWLINE_Vyps\xc3\xa1n\xc3\xadm nejm\xc3\xa9n\xc4\x9b v\xc3\xbdznamn\xc3\xbdch bit\xc5\xaf adrset ukazuje, \xc5\xbee nen\xc3\xad zarovn\xc3\xa1na na velikost slova ("dword" v x86 terminologii).'