It has been suggested that Access violation be merged into this article or section. (Discuss) A segmentation fault (often shortened to segfault) 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 that is not allowed (e.g., attempts to write to a read-only location, or to overwrite part of the operating system). Systems based on processors like the Motorola 68000 tend to refer to these events as Address or Bus errors. Image File history File links Please see the file description page for further information. ...
An access violation is the attempt by a computer process to access a memory area that it does not own or have permission to access. ...
A screenshot of computer software in action. ...
The Motorola 68000 is a 32 bit CISC microprocessor, the first member of a successful family of microprocessors from Motorola, which were all mostly software compatible. ...
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. Segmentation is one of the most common ways to achieve memory protection; another common one is paging. ...
Memory management is the act of managing computer memory. ...
An operating system is a special computer program that manages the relationship between application software, the wide variety of hardware that makes up a computer system, and the user of the system. ...
In computer operating systems, paging memory allocation algorithms divide computer memory into small partitions, and allocates memory using a page as the smallest building block. ...
On Unix-like operating systems, a process that accesses invalid memory receives the SIGSEGV signal. On Microsoft Windows, a process that accesses invalid memory receives the STATUS_ACCESS_VIOLATION exception. A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification. ...
SIGSEGV is the symbolic name for the signal thrown by computer programs making invalid memory references on POSIX compliant platforms. ...
A signal is an asynchronous event transmitted between one process and another. ...
Windows redirects here. ...
Example Here is an example of an ANSI C program that should create a segmentation fault on most platforms with memory protection: ANSI C (Standard C) is a variant of the C programming language. ...
#include <stdlib.h> int main(void) { char *p = NULL; /* p is now a NULL-pointer of type "char *" */ *p = 'x'; /* Attempt to write character 'x' at address 0 (the NULL-pointer) */ return 0; } Compiling and running it on NetBSD produces the following: NetBSD was the second freely redistributable, open source version of the BSD Unix-like computer operating systems to produce a formal release (after 386BSD) and continues to be actively developed. ...
$ cc -g3 -o segfault segfault.c $ ./segfault Segmentation fault Backtrace from gdb: A stack trace (also called backtrace) is a dump of the active stack frames left in memory by the execution of a program. ...
The GNU Debugger, usually called just GDB, is the standard debugger for the GNU software system. ...
Program received signal SIGSEGV, Segmentation fault. 0x080487b0 in main () at segfault.c:4 4 *p = 'x'; (gdb) bt #0 0x080487b0 in main () at segfault.c:4 Note that the language standard does not say anything about what happens when a null pointer is dereferenced; it invokes undefined behaviour and literally anything might happen (including but not limited to exiting successfully). The conditions under which segmentation violations occur and how they manifest themselves is specific to an operating system. In computer science, to simplify the specification and allow some flexibility in implementation, the specification sometimes defines a behavior undefined. ...
See also |