[ale] bus error vs. segmentation fault

Michelangelo Grigni mic at mathcs.emory.edu
Mon Oct 30 16:26:15 EST 2000


As I understand it, a "bus error" occurs when a processor
attempts to use a memory address that is misaligned for the
current instruction.  For example, on a sparc an int be
stored on a word (4-byte) boundary, so something like this
would fail (unless c happens to be word-aligned):

   char c;
   scanf("%d", &c);

A "segmentation fault" occurs instead when you attempt to
use a memory address disallowed by the VM subsystem.  For
example, trying to read an address in a non-existent page,
or modify an unwritable page, or execute in a
non-executable page.  The usual example:

   int *p;
   *p = 1;
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list