Subject: port-alpha/8145: Compiler alignment bug on Alpha architecture
To: None <gnats-bugs@gnats.netbsd.org>
From: Der Beagle <sopwith!snoopy@parsely.rain.com>
List: netbsd-bugs
Date: 08/04/1999 22:43:50
>Number: 8145
>Category: port-alpha
>Synopsis: egcs generates incorrect code resulting in unaligned accesses
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: port-alpha-maintainer (NetBSD/alpha Portmaster)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Aug 4 15:50:01 1999
>Last-Modified:
>Originator: Der Beagle
>Organization:
>Release: 1.4
>Environment:
System: NetBSD sopwith.uucp 1.4C NetBSD 1.4C (SOPWITH) #1: Fri Jun 4 16:11:43 PDT 1999 snoopy@machtoo.uucp:/b/usr.src/current_1999_05_25/src/sys/arch/alpha/compile/SOPWITH alpha
Note: the kernel is -current 1999-05-25, but the compiler is
from the 1.4 release.
sopwith cc -v
Using builtin specs.
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
sopwith
>Description:
The compiler generates code which requires greater alignment
than it should.
>How-To-Repeat:
Compile Ghostscript using the unix-gcc makefile.
Run the resulting binary and observe the unaligned access
complaints from the kernel.
sysctl -w machdep.unaligned_sigbus=1
Run Ghostscript from gdb.
Observe the following results:
pid 8939 (gs): unaligned access: va=0x12039a58a pc=0x12005ae30 ra=0x12005b89c op=ldl
Program received signal SIGBUS, Bus error.
0x12005ae34 in interp (pi_ctx_p=0x1203164c0, pref=0x120191266, perror_object=0x1fffff2d8)
at /usr/app/src/gs5.87/./src/interp.c:883
883 switch (r_type_xe(iref_packed)) {
The author of Ghostscript (L. Peter Deutsch, ghost@aladdin.com) says:
This is a compiler bug.
iref_packed is declared as register const ref_packed *.
ref_packed is defined in iref.h as ushort (16-bit). Also,
r_type_xe is defined in iref.h as casting the pointer to const ushort *.
Therefore, the compiler should be generating code that assumes no more
than ushort (2-byte) alignment.
Indeed, the value of iref_packed at the point of the unaligned access
is ushort (2-byte) aligned, a.k.a. even.
However, the trap message says the opcode was ldl, which is a 4- or 8-byte
load.
Peter would like to be copied on any reply regarding this problem.
>Fix:
>Audit-Trail:
>Unformatted: