$RodHat_/search

$ man 7 signal · diff

SIGSEGV vs SIGBUS

Why did this memory access fail?

SIGSEGV often points to an address or permission problem. SIGBUS can mean a mapped address could not be backed by its file, or that the hardware rejected the access. The signal alone does not locate the bug; the fault address and mapping do.

FieldSIGSEGVSIGBUS
Linux number117
FreeBSD number1110
Default actionTerminate and dump coreTerminate and dump core
Catch, block or ignoreYesYes

SIGSEGV

A process can get SIGSEGV by dereferencing an unmapped address or by writing to a mapping without write permission. A null pointer and a guard page are familiar examples.

SIGBUS

A mapped file can raise SIGBUS when the process touches a page beyond the current end of the file, including after another process truncates it. Alignment faults and hardware errors can also lead here on some systems.

Rod's field note

A core dump and the mapping list beat guessing from the signal name. For SIGBUS on an mmap-backed file, check its current size against the offset of the faulting page. For SIGSEGV, inspect the faulting address and the mapping permissions.

What to check

Record the fault address, instruction and mappings from the core or debugger. For file mappings, also check whether the backing file changed size.

Sources and scope

Default actions and Linux numbers follow signal(7). FreeBSD numbers follow the FreeBSD signal(3) manual. Numbers shown are Linux x86/arm64 and FreeBSD; other Linux architectures may differ. Installed handlers can change observed behavior except for signals that cannot be caught.

← More signal comparisons