From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078694111313.tru64-unix-managers.marc@archive.invalid> From: Paul Kitwin Date: Fri, 13 Feb 1998 07:46:51 +0000 To: tru64-unix-managers Subject: SUMMARY: Unalligned Access error X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078694111313 > Well, looks like it's sloppy code or bad compilling. =20 >=20 > Looks like my hardware and OS are good, guess I get to send this back > to the developers! >=20 >=20 > Here is the answer from DEC: >=20 >=20 > = (http://www.partner.digital.com/www-swdev/pages/Home/TECH/faqs/dunix/u > nalign.html) >=20 > How are data accessed on Alpha? > The Alpha architecture supports longword > (32-bits) and quadword (64 bits) memory accesses. Byte and word > accesses (on EV4 and EV5 Alpha Architectures) are achieved through = the > use of multiple instructions (load as a longword or quadword; mask = and > shift to retrieve the byte or word).=20 > How are data aligned on Alpha? > * Longwords (e.g. an int) are aligned on > 4-byte boundaries.=20 > * Quadwords (e.g. a long) are aligned on > 8-byte boundaries.=20 > * Float data types are aligned on 4-byte > boundaries.=20 > * Long, double, and pointers are aligned > on 8-byte boundaries.=20 > * A structure as a whole is aligned on the > boundary of the largest element contained therein.=20 > Am I getting unaligned access warnings? > On Digital UNIX systems, you can enable or > disable reporting of the "unaligned access" warnings by using:=20 > uac p - shows current process uac > setup > uac p 1 - Enables unaligned access > message control for the > current process > uac p 0 - Disables unaligned access > message control for the > current process > uac s - shows system uac setup > =20 > NOTE: Default settings for uac under Digital > UNIX V4.0 running CDE is:=20 > % uac p > parent printing is off > fixup is on > sigbus is off > What causes unaligned access errors? > * Unaligned accesses may occur for a > number of reasons. For instance, while the compiler does its best to > naturally align data and variables, it may not know enough about the > entire application to make all the correct assumptions. Some reasons > for unaligned access are:=20 > Parameters being passed into functions=20 > Pointers (64 bits) cast as ints (32 bits)=20 > * Multithreaded applications on multiple > processors, not using proper lockings techniques, may experience > synchronization problems while accessing common data through a common > address space. This is especially a problem when char, byte, and word > data are used.=20 > * Structures and unions (size, member > alignment, structure alignment, etc. are handled differently by the > Alpha architecture than by 32-bit architectures.=20 > * Library calls, such as printf(), > scanf(), malloc(), calloc(), lseek(), fsetpos() and fgetpos() are > handled differently by the Alpha architecture. i.e. size of = parameters > to these functions may differ from 32-bit systems.=20 > * Constants may have different values > between 32-bit and 64-bit systems. This becomes an issue when > exchanging data between these systems.=20 > * Accessing data in old files, or files > shared between 32-bit and 64-bit systems.=20 > How do I get rid of "unaligned access" errors? > So you see this kind of error message?!=20 > Unaligned access pid=3D2276 > va=3D11ffffd01 pc=3D120001188 ra=3D120001100 type=3Dstq > =20 > The message above says: program unalign has an > unaligned access at PC Address 0x120001188.=20 > To isolate where the error message comes from:=20 > * Write down the PC Address reported by > the message. i.e. pc=3D120001188=20 > * Run the debugger, specifying the > executable file with the unaligned access. i.e.=20 > % dbx unalign > =20 > * Set break at the pc address and run. > i.e.=20 > dbx> stopi at 0x120001188 > dbx> run > =20 > * Once stopped at the break point, use the > "where" command and find the source line for the fault.=20 > * Knowing where the problem lies, try to > fix it.=20 > Fixing the code requires an understanding of the > code and how it interfaces with other parts of the code. The > resolution may require code changes as well as specifying additional > compiler options such as -xtaso or -nomember_alignment .=20 > * Recompile, relink and try again.=20 > * A good example for the process of > finding and fixing unaligned access problems is given in THIS PAGE.=20 > Note: Additional information on this topic can > be obtained from the DEC OSF/1 AXP debugger manual or man pages on > your compiler.=20 >=20 >=20 >=20 >=20 >=20