Bug 196658 - bus error happens with memset
bus error happens with memset
Status: CLOSED WORKSFORME
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.0
ia64 Linux
medium Severity medium
: ---
: ---
Assigned To: Luming Yu
Brian Brock
:
: 196659 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-06-26 06:01 EDT by William Bai
Modified: 2013-08-05 21:42 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-08-07 10:24:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description William Bai 2006-06-26 06:01:44 EDT
Description of problem:
    Bus error in memset when used with shmat(hugetlb), memcpy. It's OK on 
x86_64(hugetlb's pagesize 2MB), but wrong on ia64(hugetlb's pagesize 256MB)


How reproducible:


Steps to Reproduce:
    The following program can duplicate the bus error.

#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);
}
Comment 1 Jason Baron 2006-06-26 10:11:06 EDT
*** Bug 196659 has been marked as a duplicate of this bug. ***
Comment 2 William Bai 2006-06-29 06:01:54 EDT
(In reply to comment #0)
> Description of problem:
>     Bus error in memset when used with shmat(hugetlb), memcpy. It's OK on 
> x86_64(hugetlb's pagesize 2MB), but wrong on ia64(hugetlb's pagesize 256MB)
> How reproducible:
> Steps to Reproduce:
>     The following program can duplicate the bus error.
> #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);
> }

    To add up, it's not caused by shmget(). I have added the following 
in /etc/sysctl.conf.

vm.nr_hugepages =              24
kernel.shmmax   =       684354560
kernel.shmmni   =              24
kernel.shmall   =         268435456

    I didn't add shmdt and shmctl, because it has been interrupted.
Comment 3 Luming Yu 2007-07-27 11:55:13 EDT
Is it reproducible with upstream kernel?
Comment 4 William Bai 2007-08-07 10:17:48 EDT
    This problem happens on RHEL4U2, but it seems ok on RHEL4U4.(In reply to 
comment #3)
> Is it reproducible with upstream kernel?


Comment 5 Luming Yu 2007-08-07 10:24:14 EDT
thanks for the update, closing it..

Note You need to log in before you can comment on or make changes to this bug.