GNU Free Documentation License . .

: ,

(. Segmentation fault segfault , . Motorola 68000 , , .

. [   408 ], « ». , .

UNIX- , , SIGSEGV. Microsoft Windows, , , STATUS_ACCESS_VIOLATION, , , Dr. Watson, Microsoft.

[]

ANSI C, :

 const char *s = "hello world";
 *(char *)s = 'H';

, , , «hello world» « ». , . s , H .

OpenBSD 4.0 :

$ gcc segfault.c -g -o segfault
$ ./segfault
Segmentation fault

gdb:

Program received signal SIGSEGV, Segmentation fault.
0x1c0005c2 in main () at segfault.c:6
6               *s = 'H';

} , gcc 4.1.1 Linux :

$ gcc segfault.c -g -o segfault
segfault.c: In function main:
segfault.c:4: error: assignment of read-only location

, , .

. .

 int* ptr = (int*)0;
 *ptr = 1;

, main , :

 int main()
 {
     main();
 }

, : , (, ), .

,

    char* p1 = NULL;  /*   ,     ,          */
    char* p2;  /*    */
    char* p3  = (char *)malloc(20);  /* ,    */
    free(p3);  /*      */

.

, , .  :

int main()
{ int const nmax=10;
  int i,n,a[n];
}


g++ , .

[] .

[]