Segmentation Fault

From the makers of InspIRCd.
Jump to: navigation, search

Information Taken From

A segmentation fault (sometimes referred to as segfault or a SIGSEGV 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).


Here is an example of an ANSI C program that should create a segmentation fault on most platforms with memory protection:

 #include <string.h>
 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/
 (gdb) bt
 #0  0x40089357 in memset () from /lib/
 #1  0x40012280 in _rtld_global () from /lib/
 #2  0x080483b0 in main ()

See Handling Segfaults in InspIRCd