Subject: bus error in mktemp
To: None <port-pc532@NetBSD.ORG>
From: Jon Buller <jonb@metronet.com>
List: port-pc532
Date: 10/24/1995 21:53:45
Well, here's a strange one I've run into. It almost looks like a
code-gen bug in gcc 2.6.3, but I re-compiled with -O, and got the
same result. Here's the mktemp code in my libc. I compiled it
with -g and ran it with gdb, and the findings are that it gets the
bus error on line 82, implying that a pointer has gone off the deep
end. Except that the pointer is actually pointing to the end of
the path parameter like it's supposed to. (BTW, the error occurs
about 20 unoptomized machine instructions into line 82, where I'd
guess the assignment is roughly taking place. It happens the first
time line 82 is executed.)
static int
_gettemp(path, doopen)
char *path;
register int *doopen;
{
extern int errno;
75 register char *start, *trv;
76 struct stat sbuf;
77 u_int pid;
78
79 pid = getpid();
80 for (trv = path; *trv; ++trv); /* extra X's get set to 0's */
81 while (*--trv == 'X') {
82 *trv = (pid % 10) + '0';
83 pid /= 10;
84 }
Any ideas? If it's really a bug, I hope it's out by 1.1 On the
other hand, I've had my machine pull some suprises on me in the
past, and this could just be another one.
Jon