Re: what is a bus error?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[Would everyone please remember to trim quoted material in your replies?
Cut out signatures, extraneous stuff, greetings, thanks ... everything
that you _aren't_ replying to. Also, in most instances, putting your new
text inline with quoted text is far more readable than simply slapping
your text at the top of the message you are replying to.   Sorry for the
rant, but it had to be said. :]

On Mon, Jan 07, 2002 at 06:24:48PM -0800, Peter Jay Salzman wrote:
> however, what exactly is a "bus error"?   can somone show me a "hello
> world" type program that barfs with a SIGBUS?  something like:

Peter, it is my understanding that SIGBUS is usually generated when the
MMU unit doesn't care for the address. Something such as the following
would tend to generate a SIGBUS on, say, sparc, whereas x86 ought to
just run slowly:

struct t {
	char a[5];
} example;

char *ptr;
int i;

ptr = example; /* or is it ptr = &example; ? or ptr = (char *) example; ? */
ptr++; /* change ptr to point one byte higher than before */
i = (int) ptr; /* BOOM */

This code ought to try to access a 4-byte-sized integer, probably
located on a memory address congruent to 1 mod 4, which will cause some
architectures to SIGBUS, and others to run slowly. (And, perhaps, still
others might run without penalty!)

And no, I have no idea how Linux on Sparc handles this. I need more
computers. :)

I hope this helps ...

-- 
People who separate manpages from the programs
they document would steal sheep.  -- apologies to Goudy

Attachment: pgp00016.pgp
Description: PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux