Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #10679

Re: C error messages

From blp@cs.stanford.edu (Ben Pfaff)
Newsgroups comp.lang.c
Subject Re: C error messages
Date 2011-09-21 13:36 -0700
Message-ID <87vcslljk9.fsf@blp.benpfaff.org> (permalink)
References <j5dh8j$dim$1@speranza.aioe.org>

Show all headers | View raw


Quentin Pope <qp19433@hotmail.NOSPAM.com> writes:

> What is the principle difference between a Bus Error and a Segmentation 
> Fault please.

It's implementation-specific.  Not all implementations have
either one.

The glibc manual describes one common distinction:

 -- Macro: int SIGSEGV
     This signal is generated when a program tries to read or write
     outside the memory that is allocated for it, or to write memory
     that can only be read.  (Actually, the signals only occur when the
     program goes far enough outside to be detected by the system's
     memory protection mechanism.)  The name is an abbreviation for
     "segmentation violation".

     Common ways of getting a `SIGSEGV' condition include dereferencing
     a null or uninitialized pointer, or when you use a pointer to step
     through an array, but fail to check for the end of the array.  It
     varies among systems whether dereferencing a null pointer generates
     `SIGSEGV' or `SIGBUS'.

 -- Macro: int SIGBUS
     This signal is generated when an invalid pointer is dereferenced.
     Like `SIGSEGV', this signal is typically the result of
     dereferencing an uninitialized pointer.  The difference between
     the two is that `SIGSEGV' indicates an invalid access to valid
     memory, while `SIGBUS' indicates an access to an invalid address.
     In particular, `SIGBUS' signals often result from dereferencing a
     misaligned pointer, such as referring to a four-word integer at an
     address not divisible by four.  (Each kind of computer has its own
     requirements for address alignment.)

     The name of this signal is an abbreviation for "bus error".

-- 
"...what folly I commit, I dedicate to you."
--William Shakespeare, _Troilus and Cressida_

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C error messages Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-09-21 20:25 +0000
  Re: C error messages blp@cs.stanford.edu (Ben Pfaff) - 2011-09-21 13:36 -0700
    Re: C error messages Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-09-22 21:07 +0000
      Re: C error messages blp@cs.stanford.edu (Ben Pfaff) - 2011-09-22 14:34 -0700
      Re: C error messages Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-22 16:05 -0600
      Re: C error messages Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-22 21:21 -0400
  Re: C error messages Nobody <nobody@nowhere.com> - 2011-09-22 18:08 +0100
  Re: C error messages Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-09-23 12:00 +0300

csiph-web