> What is bus error?

Bus error occurs when hardware tells the OS about a problematic memory
reference.  In practice, a bus error is almost always caused by a
misaligned read or write.  It's called a bus error, because the address
bus is the component that chokes if a misaligned load or store is
requested.


Alignment means that data items can only be stored at an address that
is multiple of their size.

A program to cause a bus error is:

union {
    char a[10];
    int i;
}u;

int *p = (int*) &(u.a[1]);
*p = 17;        /* the misaligned addr is p causes a bus error */


A bus error can also be generated by referencing memory that does
not physically exist.

Simply, a bus error means that the CPU disliked something about
that memory reference, while segv means that the MMU disliked
something about it.