test.c:
#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);
}
gcc test.c -o test
./test
I did't add shmdt and shmctl, because it will be interrupted by SIGBUS.
It's OK on EM64T with gcc v3.4.4. And it's also OK on IA64 with gcc v3.3.3.
But if I use gcc v3.4.4 on IA64, sigbus error happens.
--
Summary: SIGBUS on IA64 maybe caused by memcpy I
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: snowingbear at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28185