SIGSEGV

From Wikipedia, the free encyclopedia

SIGSEGV
Description: Invalid memory reference
Default action: Abnormal termination of the process
SA_SIGINFO macros
SEGV_MAPERR Address not mapped to object
SEGV_ACCERR Invalid permissions for mapped object

On POSIX-compliant platforms, SIGSEGV is the signal thrown by computer programs making invalid memory references, or segmentation faults. The symbolic constant for SIGSEGV is defined in the header file signal.h. Symbolic signal names are used because signal numbers can vary across platforms.

[edit] Etymology

SIG is a common prefix for signal names. SEGV is an abbreviation of segmentation violation.

[edit] Usage

Computer programs may throw SIGSEGV for improper memory handling (see segmentation fault). The operating system may inform the application of the nature of the error using the signal stack, which developers can use to debug their programs or handle errors.

The default action for a program upon receiving SIGSEGV is abnormal termination. This action will end the process, but may generate a core file to aid debugging, or perform some other platform-dependent action. For example, Linux systems using the grsecurity patch may log SIGSEGV signals in order to monitor for possible intrusion attempts using buffer overflows.

SIGSEGV can be caught; that is, applications can request what action they want to occur in place of the default. Examples of such action might be ignoring it, calling a function, or restoring the default action. In some circumstances, ignoring SIGSEGV results in undefined behavior.[1]

An example of an application that might handle SIGSEGV is a debugger, which might check the signal stack and inform the developer of what happened, and where the program terminated.

SIGSEGV is usually generated by the operating system, but users with appropriate permissions can use the kill system call or kill command (a userland program, or sometimes a shell builtin) to send the signal to a process at will.

POSIX Signals
SIGABRT | SIGALRM | SIGFPE | SIGHUP | SIGILL | SIGINT | SIGKILL | SIGPIPE | SIGQUIT | SIGSEGV | SIGTERM | SIGUSR1 | SIGUSR2 | SIGCHLD | SIGCONT | SIGSTOP | SIGTSTP | SIGTTIN | SIGTTOU | SIGBUS | SIGPOLL | SIGPROF | SIGSYS | SIGTRAP | SIGURG | SIGVTALRM | SIGXCPU | SIGXFSZ | Realtime Signals are user definable—SIGRTMIN+n through SIGRTMAX.
Common non-POSIX signals and synonyms
SIGIOT | SIGEMT | SIGSTKFLT | SIGIO | SIGCLD | SIGINFO | SIGPWR (SIGINFO) | SIGLOST | SIGWINCH | SIGUNUSED
In other languages