Subject: Re: unaligned access
To: None <, port-alpha@NetBSD.ORG>
From: Ross Harvey <>
List: port-alpha
Date: 05/19/1998 18:20:04
> From Tue May 19 18:02:04 1998
> Date: Tue, 19 May 1998 20:33:15 -0400
> To: port-alpha@NetBSD.ORG
> From: nm <>
> Subject: unaligned access
> will an unaligned access cause a program to fail on netbsd/alpha 1.3?
> thanks
> nick

No, they are patched up and the program continues. It's definitely
something you want to fix, though, since it means someone did something
wrong. For example, you might get this when a program gets a network
datagram, computes an offset from the start, and then manufactures a
struct or "long" pointer for that address. The correct solution is to
include <string.h> and use memcpy() to copy the bits to a structure
or "long" type object that the compiler has allocated and made addressable.

Sometimes, you get this on even uglier bugs or just plain uninitialized
pointers. Sometimes you get this because something that is supposed to
be an "int" or, really "int32_t" is made a "long". There is very frequently
a bug somewhere in the vicinity.

You can control the treatment of unaligned memory ops with the following
sysctl names:

	machdep.unaligned_print = 1
	machdep.unaligned_fix = 1
	machdep.unaligned_sigbus = 0