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

Re: Assorted Bus Errors - common problem?



Johan Zandin wrote:
> 
> On Thu, 14 Mar 2002, Ben Collins wrote:
> 
> >On Thu, Mar 14, 2002 at 07:19:00AM -0500, MIke Culbertson wrote:
> >> The general question I am asking is whether or not these bus errors are a
> >> common sparc/linux related problem,
> 
> >They are a common sparc problem, but not a problem in sparc.
> >The basic issue is unaligned data being accessed in the program, which
> >is a bug in that program (one which doesnt' show on i386 for example).
> 
> Compiling the failing application with the gcc-flag "-Wcast-align" may
> detect some of these problems. (The compiler itself should not misalign
> things, so casting is usually a major suspect.)
> 
> If the application casts byte arrays into struct types (for example to
> decode packet contents for some network protocol), it might also help to
> declare the struct types as packed, using "__attribute__((__packed__))".
> Apart from avoiding padding within the struct, this will alert the
> compiler that the struct members may be misaligned. Code accessing the
> struct members will then be compiled to handle that situation.

Do we know that these are un/bad aligned data problems?  Not that I have
a hard time believing that, because I don't.  But is it just a
coincidence that they are both network apps (nmap and tcpdump) that
twiddle with raw network data?  And the SPARC is network order and the
x86 is, well, x86 order?  It could be that a library didn't do a ntoh()
or hton() when it should have.

a



Reply to: