In unix, a bus error results in your process receiving a SIGBUS signal. Bus errors are typically caused by attempts to access bad memory or attempts to access data that is not word aligned on architectures that require multibyte data to be word aligned.

Examples of "bad" memory might include areas that are reserved and therefore could never be valid, or areas of device mapped memory that is either nonexistant or currently in an error state.

On the Sun SPARC architecture, the following program generates a bus error due to a misaligned memory access.

main()
{

int *p = 1;

printf("%d\n",*p);
}

Note that if you change the 1 to a 0, you get a segmentation fault since page zero is not mapped. On Intel architectures and other architectures that allow non-word aligned memory access, both might generate a segment fault. On some architectures, page zero is mapped, and reads are allowed, so this may not generate any fault.

 

Bus error: Passengers dumped.