From owner-freebsd-alpha Thu Feb 15 4: 1:12 2001 Delivered-To: freebsd-alpha@freebsd.org Received: from altrade.nijmegen.inter.nl.net (altrade.nijmegen.inter.nl.net [193.67.237.6]) by hub.freebsd.org (Postfix) with ESMTP id 999C237B491 for ; Thu, 15 Feb 2001 04:01:06 -0800 (PST) Received: from ntpc by altrade.nijmegen.inter.nl.net via 1Cust34.tnt18.rtm1.nl.uu.net [213.116.130.34] with SMTP id NAA20203 (8.8.8/1.3); Thu, 15 Feb 2001 13:01:00 +0100 (MET) Reply-To: From: "Peter Blok" To: "'Terry Lambert'" , "'Andrew Gallatin'" Cc: , Subject: RE: unaligned access Date: Thu, 15 Feb 2001 12:59:00 +0100 Message-ID: <000001c09746$af96e2a0$8a02a8c0@ntpc> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <200102150046.RAA10115@usr08.primenet.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Terry, and others. Thanks for the hints. One big cause was the embedded alloc routines, that doesn't do aligning. The next buffer allocated was unaligned, because the previous size was unaligned. I haven't looked closely enough to the structures. I also had one unaligned access in a varargs construction. Haven't found the cause yet. Peter -----Original Message----- From: Terry Lambert [mailto:tlambert@primenet.com] Sent: Thursday, February 15, 2001 01:46 To: Andrew Gallatin Cc: Peter.Blok@inter.NL.net; freebsd-alpha@FreeBSD.ORG Subject: Re: unaligned access > > I am trying to port mpd-netgraph to alpha, but i'm getting a > > lot of uac's. I am trying to use gdb, but I am not used to > > gdb. When I try to lookup the address it tells me it is > > outside the map. > > > > Is it possible to make it core dump instead of this warning? > > It would be nice if you can say: run this command and core > > dump on uac. > > > > Are tools available to determine in which function the uac > > takes place? I can make something myself with perl and nm, > > but if there is already something out there? > > > > Which compiler options bring this up at compile time? > > I don't know what mpd netgraph is. Can you elaborate further? Is the > kernel crashing, or is it a userland app? > > If it is a userland app, try running uap -s prior to invoking gdb. > Then run gdb on the app. You should get a SIGBUS at the PC of the > unaligned access. If gdb misbehaves, try increasing the size of the > heuristic-fence-post. Eg: > > (gdb) set heuristic-fence-post 0xffffffffffffffff The mpd program is Archie's multiplink PPP daemon; I'm pretty sure he had a pure kernel version released before he left Whistle, didn't he? It has to be the user space stuff, or it would be a panic, and he probably would be unable to use gdb. The "uap -s" program will work. It is a single instance overrride for the command argument. Without the gdb involved, it will core dump (which I've always found a lot more useful than stepping through with gdb, for all but one problem, over the years). There is also a sysctl, which will turn off the unaligned access trap fixup, and crash the program; I don't know why fixup is the default these days. Apparently, mpd hates the fixup process, since you'd expect it to work. Since the Alpha has x86 byte order, I'd suggest that the structure where data is having its unaligned dereference is probably a structure element dereference off a pointer cast from a character buffer. Look for your bug to go away if you use a "#pragma pack(1)" around the structure declarations used by the program. If the data is naturally aligned, and it's just the character buffer that's being cast that's the problem (been too long since I've had to read entrails in the PPP code, sorry), then you should be able to get away with creating an aligned buffer to which you copy the character buf data, prior to dereference. Even if you change the packing, and rely on the fixup, or you use an aligned buffer that you copy data into from an unaligned one, I suspect that you will still end up with unaligned fixups (I can't believe the PPP designers thought that far ahead). Getting rid of the unaligned fixups will probably end up being a bear. This may already be there, since I'm running rather old Alpha code (multia didn't work again until recently, and SMP work means "Stable Machine Precluded" to me), but it might be useful to add a "uap" argument that will suppress the printing of the meessages on a per process basis (sort of the opposite of the "cause a segmentation fault" flag). This would let the console be usable for things like CVSup of new code, when the process that provides yor connection to the network is faulting all over the place, and you need to download new code for it. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message