SIGBUS
From Wikipedia, the free encyclopedia
Description: | Bus error |
---|---|
Default action: | Abnormal termination of the process |
SA_SIGINFO macros | |
BUS_ADRALN |
invalid address alignment |
BUS_ADRERR |
non-existent physical address |
BUS_OBJERR |
object-specific hardware error |
On POSIX-compliant platforms, SIGBUS is the signal thrown by computer programs causing a bus error. The symbolic constant for SIGBUS 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. BUS refers to the data bus in the context of a bus error.
[edit] Usage
Computer programs may throw SIGBUS for improper memory handling:
- Invalid address alignment
- The program has attempted to read or write data that does not fit the CPU's memory-alignment rules.
- Non-existent physical address
- This is equivalent to a segmentation fault, but for a physical address rather than a virtual address.
- Object-specific hardware error
- This is far less common, but it is present in Solaris, when virtual memory pages have disappeared (e.g. accessing an mmaped file which has been truncated. [1])
For further discussion, see bus error.
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 SIGBUS is abnormal termination. This will end the process, but may generate a core file to aid debugging, or other platform dependent action.
SIGBUS can be handled (caught). That is, applications can request what action they want to occur. Examples of such action might be ignoring it, calling a function, or restoring the default action. In some circumstances, ignoring SIGBUS results in undefined behaviour.
An example of an application that might handle SIGBUS is a debugger, which might check the signal stack and inform the developer of what happened, and where the program terminated.
SIGBUS 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 |