Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: signal BUS (invalid address alignment)

Reply
Thread Tools

Re: signal BUS (invalid address alignment)

 
 
Ron Natalie
Guest
Posts: n/a
 
      08-21-2003

"Suresh" <> wrote in message news:...

> My C++ program crashes with "signal BUS (invalid address alignment)" at
> random places. Does anyone know what this could mean ? What is the cause of
> signal BUS ?


I suspect, it's "invalid address alignment" just as it says. Typically, you are violating
the alignment constranits, etc...

char foo[10];
*(int*)(foo+1) = 1;

for example on a machine that requires int's to be aligned on some multiple number
of bytes.

The historical word SIGBUS comes from the UNIX signal names which was derived
from the PDP-11 BUS ERROR processor trap. There were two things that would cause
this trap. One was accessing words on odd addresses. The other was accessing a
memory address that, while mapped in to your address space, didn't answer (missing or
otherwise not responding).



 
Reply With Quote
 
 
 
 
Artie Gold
Guest
Posts: n/a
 
      08-21-2003
Ron Natalie wrote:
> "Suresh" <> wrote in message news:...
>
>
>>My C++ program crashes with "signal BUS (invalid address alignment)" at
>>random places. Does anyone know what this could mean ? What is the cause of
>>signal BUS ?

>
>
> I suspect, it's "invalid address alignment" just as it says. Typically, you are violating
> the alignment constranits, etc...
>
> char foo[10];
> *(int*)(foo+1) = 1;
>
> for example on a machine that requires int's to be aligned on some multiple number
> of bytes.
>
> The historical word SIGBUS comes from the UNIX signal names which was derived
> from the PDP-11 BUS ERROR processor trap. There were two things that would cause
> this trap. One was accessing words on odd addresses. The other was accessing a
> memory address that, while mapped in to your address space, didn't answer (missing or
> otherwise not responding).
>


While you may have diagnosed the problem, the OP mentioned "random"
crashes; a pure misalignment situation as you've illustrated would
happen directly at the site. [NFI]

HTH,
--ag


--
Artie Gold -- Austin, Texas

 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      08-21-2003

"Artie Gold" <> wrote in message news:...

>
> While you may have diagnosed the problem, the OP mentioned "random"
> crashes; a pure misalignment situation as you've illustrated would
> happen directly at the site. [NFI]


Well it's not clear what he means by random. Most likely if it means it doesn't
always happen, that it's a uninitialized variable causing a misaligned pointer
access. It can also because his program just sometimes happens to do it's
accesses aligned and sometimes not alligned without any true "randomness"
but just fails or not fails in different situations.


 
Reply With Quote
 
Artie Gold
Guest
Posts: n/a
 
      08-21-2003
Ron Natalie wrote:
> "Artie Gold" <> wrote in message news:...
>
>
>>While you may have diagnosed the problem, the OP mentioned "random"
>>crashes; a pure misalignment situation as you've illustrated would
>>happen directly at the site. [NFI]

>
>
> Well it's not clear what he means by random. Most likely if it means it doesn't
> always happen, that it's a uninitialized variable causing a misaligned pointer
> access. It can also because his program just sometimes happens to do its
> accesses aligned and sometimes not alligned without any true "randomness"
> but just fails or not fails in different situations.
>


Valid point!

....and unless it _is_ flaky hardware (could be, I guess) it's obviously
not random in any real sense. It can sure _look_ that way though!

--ag

BTW -- [NFI] == no flame intended


--
Artie Gold -- Austin, Texas

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple individual bidirectional signal concatenated into 1bidirectional bus Amish Rughoonundon VHDL 1 06-11-2012 09:02 AM
Address Bus and External Data Bus Confusion LoXodonte A+ Certification 1 04-18-2006 09:09 PM
sprintf leading up to bus error (signal 10) steve C Programming 26 07-20-2005 01:26 AM
Re: signal BUS (invalid address alignment) Mike Wahler C++ 2 08-22-2003 02:23 PM
Re: signal BUS (invalid address alignment) Artie Gold C++ 0 08-21-2003 03:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57