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

Re: Assorted Bus Errors - common problem?

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.

/Johan Zandin

Reply to: