Segmentation Fault

A segmentation fault (sometimes referred to as segfault for short) is a particular error condition that can occur during the operation of computer software. In short, a segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way it is not allowed to (eg, attempts to write a read-only location). Systems based on processors like the Motorola 68000 tend to refer to these events as Address or Bus errors. Segmentation is one approach to memory management and protection in the operating system. It has been superseded by paging for most purposes, but much of the terminology of segmentation is still used, "segmentation fault" being an example. Some operating systems still have segmentation at some logical level although paging is used as the main memory management policy. UNIX programmers are likely to use the term synonymously with "segmentation violation" and the associated signal, SIGSEGV. Microsoft Windows users are likely to see a General protection fault, but programmers still use the term segmentation fault. (The debugger of MS Visual Studio does not use the term "segmentation fault" but reports an "access violation".) The humorous website Segfault was named after this error.

Example

Here is an example of an ANSI C program that should create a segmentation fault on most platforms with memory protection:
   #include       int main()   {     memset((char *)0x0, 42, 200);   } 
Compiling and running it on Linux produces the following:
   % gcc -o segfault segfault.c   % ./segfault   Segmentation fault   % 
Backtrace from gdb:
   Program received signal SIGSEGV, Segmentation fault.   0x40089357 in memset () from /lib/libc.so.6   (gdb) bt   #0  0x40089357 in memset () from /lib/libc.so.6   #1  0x40012280 in _rtld_global () from /lib/ld-linux.so.2   #2  0x080483b0 in main () 

 

<< PreviousWord BrowserNext >>
simultaneity
spacetime
stephen hawking
simcity
sofonisba anguissola
samegame
sather
serotonin
lawrence alma tadema
surrealism
statics
southern cross
ship transport
isles of scilly
st. john's, antigua and barbuda
sigtuna municipality
self similarity
svo
small beer
sov
sambia (baltic)
strange matter
sovereignty
semen
alliance of the democratic left
sld
source separation
stephen cole kleene
shabbat
saki
static code analysis
samuel mudd
secure shell
generalissimo francisco franco is still dead
son house
sex worker
sexually transmitted infection
stphane mallarm
submarine
second epistle to the thessalonians
slam poetry
sestina
song
sir gawain and the green knight