Bug#413078: Gcc does not work after kernel upgrade
Tried on another 64-bit machine, but this is sparc64.
This kernel gave some noise.
> Kernel unaligned access at TPC[432d98] sys32_gettimeofday+0x20/0x80
> Kernel unaligned access at TPC[432da8] sys32_gettimeofday+0x30/0x80
> Bus error
It looks like both time() <time.h> and gettimeofday() <sys/time.h>
could be broken.
Tried setting the struct timeval without call and it worked.
Linux or libc6?
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/time.h>
#include <string.h>
#include <time.h>
#include <alloca.h>
/* +Ve == bytes written -Ve == bytes required */
int vunprintf(int fdout, int r, const char *fmt, va_list ap) {
int i;
char *p;
p=alloca(r);
i=vsnprintf(p,r,fmt,ap);
if(i<0)
return 1-2*r;
if(i<r)
return write(fdout,p,i);
else
return -i;
}
/* +Ve == bytes written -Ve == failure */
int vuprintf(int fdout, const char *fmt, va_list ap) {
int i=BUFSIZ;
i=vunprintf(fdout, i, fmt, ap);
if(i<0)
i=vunprintf(fdout, 1-i, fmt, ap);
return i;
}
int uprintf(int fdout, const char *fmt, ...) {
va_list ap;
int r;
va_start(ap, fmt);
r=vuprintf(fdout, fmt, ap);
va_end(ap);
return r;
}
int uputs(char *s, int fdout) {
int l;
l=strlen(s);
if(l>0)
return write(fdout,s,l);
else
return l;
}
int main() {
char *s, h[32], r[64];
int l;
struct timeval *tp;
/* time_t tr; */
/* tr=time(0); */ /* BROKEN arg must be NULL */
/*
l=gettimeofday(tp, 0);
*/
tp=alloca(sizeof(struct timeval));
tp->tv_sec=123456789;
tp->tv_usec=123456;
gethostname(h,32);
h[31]=0;
/* Maildir date for message file names */
/*
uprintf(1,"sizeof(tp->tv_sec)==%d %u\n",sizeof(tp->tv_sec),tp->tv_sec);
uprintf(1,"sizeof(tp->tv_usec)==%d %u\n",sizeof(tp->tv_usec),tp->tv_usec);
*/
uprintf(1,"%lu.M%06luP%d.%s\n",tp->tv_sec,
tp->tv_usec,getppid(),h);
/*
fprintf(stdout,"%lu.M%06luP%d.%s\n",tp->tv_sec,
tp->tv_usec,getppid(),h);
fflush(stdout);
*/
/* RFC 4155 date for "^From " headers */
s=asctime(gmtime(&(tp->tv_sec)));
uputs(s,1);
/* RFC 822 date for emails */
strftime(r,64,"%a, %e %b %Y %H:%M:%S %z%n",
localtime(&(tp->tv_sec)));
r[63]=0;
uputs(r,1);
return 0;
/*
exit(0);
*/
}
Linux sparc 2.6.18-3-sparc64 #1 Mon Dec 4 17:47:35 GMT 2006 sparc64 GNU/Linux
libc6 2.3.6.ds1-8
Kernel unaligned access at TPC[432d98] sys32_gettimeofday+0x20/0x80
Kernel unaligned access at TPC[432da8] sys32_gettimeofday+0x30/0x80
Bus error
andrewb@sparc:~/src$ gcc-3.3 -o 4155-date 4155-date.c
andrewb@sparc:~/src$ ./4155-date
18583.M116760P3028.sparc
Thu Jan 1 05:09:43 1970
Thu, 1 Jan 1970 13:09:43 +0800
andrewb@sparc:~/src$ gcc-3.4 -o 4155-date 4155-date.c
andrewb@sparc:~/src$ ./4155-date
18583.M116760P3028.sparc
Thu Jan 1 05:09:43 1970
Thu, 1 Jan 1970 13:09:43 +0800
andrewb@sparc:~/src$ gcc-4.0 -o 4155-date 4155-date.c
andrewb@sparc:~/src$ ./4155-date
Kernel unaligned access at TPC[432d98] sys32_gettimeofday+0x20/0x80
Kernel unaligned access at TPC[432da8] sys32_gettimeofday+0x30/0x80
Bus error
andrewb@sparc:~/src$ gcc-4.1 -o 4155-date 4155-date.c
andrewb@sparc:~/src$ ./4155-date
Kernel unaligned access at TPC[432d98] sys32_gettimeofday+0x20/0x80
Kernel unaligned access at TPC[432da8] sys32_gettimeofday+0x30/0x80
Bus error
andrewb@sparc:~/src$ sparc32 gcc-4.1 -o 4155-date 4155-date.c
andrewb@sparc:~/src$ ./4155-date
Kernel unaligned access at TPC[432d98] sys32_gettimeofday+0x20/0x80
Kernel unaligned access at TPC[432da8] sys32_gettimeofday+0x30/0x80
Bus error
sparc:/home/andrewb/src# apt-get install libc6
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
libc6-dev libc6-dev-sparc64 libc6-sparc64
Suggested packages:
glibc-doc
The following packages will be upgraded:
libc6 libc6-dev libc6-dev-sparc64 libc6-sparc64
4 upgraded, 0 newly installed, 0 to remove and 231 not upgraded.
Need to get 11.4MB of archives.
After unpacking 12.3kB disk space will be freed.
Do you want to continue [Y/n]? y
Get:1 http://ftp.wa.au.debian.org etch/main libc6-dev-sparc64 2.3.6.ds1-11 [1728kB]
Get:2 http://ftp.wa.au.debian.org etch/main libc6-dev 2.3.6.ds1-11 [2097kB]
Get:3 http://ftp.wa.au.debian.org etch/main libc6-sparc64 2.3.6.ds1-11 [3649kB]
Get:4 http://ftp.wa.au.debian.org etch/main libc6 2.3.6.ds1-11 [3925kB]
Fetched 11.4MB in 3m45s (50.4kB/s)
(Reading database ... 129863 files and directories currently installed.)
Preparing to replace libc6-dev-sparc64 2.3.6.ds1-8 (using .../libc6-dev-sparc64_2.3.6.ds1-11_sparc.deb) ...
Unpacking replacement libc6-dev-sparc64 ...
Preparing to replace libc6-dev 2.3.6.ds1-8 (using .../libc6-dev_2.3.6.ds1-11_sparc.deb) ...
Unpacking replacement libc6-dev ...
Preparing to replace libc6-sparc64 2.3.6.ds1-8 (using .../libc6-sparc64_2.3.6.ds1-11_sparc.deb) ...
Unpacking replacement libc6-sparc64 ...
Preparing to replace libc6 2.3.6.ds1-8 (using .../libc6_2.3.6.ds1-11_sparc.deb)
...
Unpacking replacement libc6 ...
Setting up libc6 (2.3.6.ds1-11) ...
INIT: version 2.86 reloading
Setting up libc6-sparc64 (2.3.6.ds1-11) ...
Setting up libc6-dev (2.3.6.ds1-11) ...
Setting up libc6-dev-sparc64 (2.3.6.ds1-11) ...
No change after updating libc6 to 2.3.6.ds1-11.
Reply to: