Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
To: axp-list@redhat.com
Subject: Re: RH 6.0 and unaligned traps
Date: Wed, 16 Jun 1999 09:01:58 -0600 (MDT)	[thread overview]
Message-ID: <199906161501.JAA19578@ellpspace.math.ualberta.ca> (raw)
In-Reply-To: <199906160950.LAA02642@alpha.mdy.univie.ac.at> from "Stefan Boresch" at Jun 16, 99 11:50:12 am

Stefan Boresch wrote:
> 
> Is there a more general solution to the various unaligned trap
> messages resurfacing in RH 6.0 in the works.

The only one I know if fixing the code.

>  but my syslog abounds with such messages from emacs,
> in.identd and Banner

Smells like "new and improved" libraries may be somehow responsible
for that.  I do not know that for sure but this has that feel.

> but I am happy to recompile programs if someone with a
> much deeper understanding of Unix system programming than myself can
> locate the troublespots...

Likely the best approach I know is to use something which Richard
Henderson posted on this list some year ago and which I quote below.
This converts unaligned access attempts into exceptions and you may catch
them in a debugger.  The thing is that unaligned traps often indicate
real bugs - like misaligned stack, dubious access through "smart(-ass)"
pointer games and the like.  In general you do not want fetches and
stores to happen through pointers which were cast to something (like
cast to *long) with a stricter alignment requirements than originals
(say individual cells in an array of chars).  If you really need
something like that you require a properly aligned copy.

With identified libraries issues there is no much point in talking
about it on this list; beyond notifying fellow sufferers.  People
responsible for glibc should get bug reports and the more the merrier.

  Michal

 Date: Mon, 6 Apr 1998 20:38:02 -0700
 From: Richard Henderson <rth@dot.cygnus.com>
 Subject: Re: tracking down unaligned accesses


 [ CC'ed to axp-list because of general interest. ]

 On Mon, Apr 06, 1998 at 11:15:14PM -0400, Gene McCulley wrote:
 > I am currently porting a large (1.6 million lines of code) application
 > to the Alpha.  It has worked previously with the -taso stuff, but now
 > I am making it 64-bit clean and eliminating all of the sizeof(void *)
 > assumptions.  I am working under Digital Unix, but this step was
 > necessary so that we can move to Linux/Alpha.
 > 
 > I am getting the unaligned access messages:
 > Unaligned access pid=5293 <sim> va=0x1420f365c pc=0x1207ac030 ra=0x1207abff4 inst=0xb54c0000
 > 
 > Is there a way to trap these in the debugger or some other way to
 > facilitate finding these?

 The following will tell both Digital Unix and Linux (post 2.1.20 or so)
 to deliver a SIGBUS rather than fix up the access.  This makes the 
 problem significantly easier to debug.


 r~

 --VbJkn9YxBvnuCH5J
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="unaligned.c"

 #ifndef __linux__
 #include <sys/sysinfo.h>
 #else
 #include <asm/sysinfo.h>
 #include <asm/unistd.h>

 static int setsysinfo(unsigned long op, void *buffer, unsigned long size,
		       int *start, void *arg, unsigned long flag)
 {
   syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);
 }
 #endif

 void trap_unaligned(void)
 {
   unsigned int buf[2];
   buf[0] = SSIN_UACPROC;
   buf[1] = UAC_SIGBUS | UAC_NOPRINT;
   setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);
 }

 #ifdef TEST
 static int tmp[2];
 int main(int ac)
 {
   if (ac > 1) 
     trap_unaligned();
   return *(int *)((char *)tmp + 1);
 }
 #endif

 --VbJkn9YxBvnuCH5J--


      reply	other threads:[~1999-06-16 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-16  9:50 RH 6.0 and unaligned traps Stefan Boresch
1999-06-16 15:01 ` Michal Jaegermann [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox