Python 2.1 on SGI

Pete Forman pete.forman at westerngeco.com
Wed May 16 12:29:30 EDT 2001


RajGopal Srinivasan <raj at grserv.med.jhmi.edu> writes:

> 	Curiously, one can compile with optimization and not have a
> SIGBUS if the CONVERT_TO_DOUBLE macro is slightly modified as
> follows:
> [snip]

This does not surprise me.  IRIX, or rather the MIPS CPU, has some of
the strictest alignment requirements.  Doubles have to be stored on 8
byte boundaries.  Other CPUs such as x86 (Linux, Win32) or POWER (AIX)
have no restrictions on how doubles are aligned.  SPARC (Solaris) can
be aligned to 1, 2, 4 or 8 byte boundaries depending on compiler and
linker options.

Programs which do their own structure management have to be aware of
these issues.  A typical example is allocating an array of char and
then storing a double somewhere in it.

Whether or not a SIGBUS happens can seem random.  Inserting a debug
statement or altering the optimization can move the memory layout
subtly so that a double that was aligned is now moved by 4 bytes, say.

An example C program to investigate these issues is available at my
web site <http://www.crosswinds.net/~petef/c/align.c>.
-- 
Pete Forman                 -./\.- Disclaimer: This post is originated
WesternGeco                   -./\.-  by myself and does not represent
pete.forman at westerngeco.com     -./\.-  opinion of Schlumberger, Baker
http://www.crosswinds.net/~petef  -./\.-  Hughes or their divisions.



More information about the Python-list mailing list