Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!convex!sneaky!gordon From: gordon@sneaky Newsgroups: net.news.b Subject: Re: Limits on 4.2BSD lseek(2)? Message-ID: <-1273946@sneaky> Date: Mon, 19-May-86 23:34:00 EDT Article-I.D.: sneaky.-1273946 Posted: Mon May 19 23:34:00 1986 Date-Received: Sun, 25-May-86 12:45:38 EDT References: <717@smeagol.UUCP> Lines: 44 Nf-ID: #R:smeagol.UUCP:717:sneaky:-1273946:000:1847 Nf-From: sneaky!gordon May 19 22:34:00 1986 > In the Netnews 2.10.3 4.3bsd-beta 6/6/85 distibution, there is a program > called article (written by Peter Honeyman, down!honey) that comes in > the `misc' directory. This program will take an article message ID > (like 1052@ellie, 1424@lll-crg, etc.), look it up in the dbm version > of the news history file, and if it finds it, will print out ... ... > The problem I have found, is that more often than not, the program will > blow up on a Bus Error. This happens on a Sun 2-120 workstation, running > Sun OS 2.0 (4.2BSD based). The cause of this Bus Error is an execution > of lseek(2). A subroutine looks for the article ID in question, and returns > a datum that has a pointer to the entry in the history dbm file. I found this same code in news 2.10.2. The data stored by dbm is an lseek() offset into the history file. The data returned by dbm's fetch() is a pointer to an *UNALIGNED* lseek() offset. Depending on your processor, you get bus errors, or the processor quietly uses the long word which contains the byte your pointer is pointing at, giving bozo results. If the data happens to be aligned right for your processor, it works. > It then calls lseek(2) with this pointer dereferenced in order to get to > that line in the history file. I doubt it gets a chance to actually call lseek(). > if (lseek(fd, *(long *) content.dptr, 0) < 0) > continue; Does lint say "Possible pointer alignment problem"? Try something like: { long scratchvar; /* maybe should be off_t instead */ int i; /* can also use bcopy or something similar */ for (i = 0; i < sizeof(long); i++) ((char *) &scratchvar)[i] = content.dptr[i]; if (lseek(fd, scratchvar, 0) < 0) continue; } Gordon Burditt ...!convex!ctvax!trsvax!sneaky!gordon ...!ihnp4!sys1!sneaky!gordon