From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 7573 invoked from network); 16 Jun 1999 15:53:58 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 16 Jun 1999 15:53:58 -0000 Received: from ellpspace.math.ualberta.ca (michal@ellpspace.math.ualberta.ca [129.128.88.19]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id LAA28335 for ; Wed, 16 Jun 1999 11:02:14 -0400 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.8/8.8.8) id JAA19578 for axp-list@redhat.com; Wed, 16 Jun 1999 09:01:58 -0600 From: Michal Jaegermann Message-Id: <199906161501.JAA19578@ellpspace.math.ualberta.ca> Subject: Re: RH 6.0 and unaligned traps To: axp-list@redhat.com Date: Wed, 16 Jun 1999 09:01:58 -0600 (MDT) In-Reply-To: <199906160950.LAA02642@alpha.mdy.univie.ac.at> from "Stefan Boresch" at Jun 16, 99 11:50:12 am Content-Type: text 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 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 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 #else #include #include 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--