unexpected bus error on IA64

William <[email protected]> Wed, 28 Jun 2006 13:30:49 +0800
Newsgroups gmane.linux.redhat.ia64.general
Message-ID <[email protected]>
     I encountered unexpected bus error when using RHELU2. The kernel
is 2.6.9, libc2.3.4 and gcc gcc version 3.4.4 20050721 (Red Hat
3.4.4-2). The following program will cause bus error on IA64(I didn't
detach and shmctl here because it has been interrupted by bus error).
It's OK on RHELU2+x86_64 and SUSE+IA64, but wrong on RHELU2+IA64:
#include <stdio.h>
#include <sys/types.h>
#include <sys/shm.h>

int main()
{
   int i = 0;
   int shmid[3];
   void *addr[3];
   for (i=0; i<3; i++) {
     shmid[i] = shmget(IPC_PRIVATE, 256*1024*1024ULL,
SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
     if (shmid[i] < 0) {
         perror("shmget");
         break;
     }
   }

   addr[0] = shmat(shmid[0], NULL, SHM_RND | SHM_UNLOCK);
   printf("addr0 is %lx\n", addr[0]);
   addr[1] = shmat(shmid[1], (void *)addr[0]+256 * 1024 *1024ULL,
SHM_RND | SHM_UNLOCK);
   printf("addr1 is %lx\n", addr[1]);
   memcpy((void *)addr[1], (void *)addr[0], 256*1024*1024ULL);
   addr[2] = shmat(shmid[2], NULL, SHM_RND | SHM_UNLOCK);
   printf("addr2 is %lx\n", addr[2]);
   memset((void *)addr[2], 0, 256*1024*1024ULL);
}
   The bus error occurs here in the last memset():
dbb40:	11 00 18 30 89 1d 	[MIB]       stf8 [r24]=f6,128

     I found the address in register r24 is 0x8000000020000000. It
should be aligned.
So I don't know where the bus error comes from. Could you please tell
me why? Thank you.