1

Please someone help with below share memory proble on arm, why memset fails?

kernel-arch - aarch64

user-arch - arm

every time dolagent.app run, sigbus err occurred, backtrace with the core shows memset is the last line,

create shared memdolagent.app[961]: unhandled level 3 translation fault (7) at 0xf69b1000, esr 0x92000047
pgd = ffffffc0142f6000
[f69b1000] *pgd=000000001b5ae003, *pud=000000001b5ae003, *pmd=00000000140a1003, *pte=0000000000000000

CPU: 3 PID: 961 Comm: dolagent.app Tainted: P                4.1.45 #4
Hardware name: Broadcom-v8A (DT)
task: ffffffc01c30cac0 ti: ffffffc014268000 task.ti: ffffffc014268000
PC is at 0xf6a46670
LR is at 0x3961b8
pc : [<00000000f6a46670>] lr : [<00000000003961b8>] pstate: 200d0010
sp : 00000000ffae4c78
x12: 0000000000000000 
x11: 00000000ffae4c7c x10: 00000000f715f000 
x9 : 0000000000000000 x8 : 0000000000000000 
x7 : 0000000000000000 x6 : 0000000000149f00 
x5 : 0000000000000000 x4 : 000000000096d984 
x3 : 00000000f69b1000 x2 : 000000000000e0f8 
x1 : 0000000000000000 x0 : 00000000f69b1000 

potentially unexpected fatal signal 7.

code:

void showTechShareMemoryInit(void)
{
   int fd;

   if((fd = shm_open("/showTechShm",O_RDWR|O_CREAT,0777)) == -1)
   {
      printf("showTech shm_open failed.\r\n");
      exit(1);
   }

   if(ftruncate(fd,sizeof(showTechElementT)*MAX_SHOWTECH_NUM) == -1)
   {
       printf("showTech ftruncate failed.\r\n");
       exit(1);
   }

   if((showTechElements = mmap(NULL,sizeof(showTechElementT)*MAX_SHOWTECH_NUM,
                    PROT_READ|PROT_WRITE,MAP_SHARED,fd,0)) == MAP_FAILED)
   {
       perror("showTech mmap failed");
       exit(1);
   }
   if(showTechElements == NULL)
   {
       exit(1);
   }

    memset(showTechElements, 0, sizeof(showTechElementT)*MAX_SHOWTECH_NUM);
}

notes: struct showTechElements is defined with __attribute((aligned (4))).

#define MAX_SHOWTECH_NUM 300

sizeof(showTechElementT) will get 192

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
jackxie
  • 33
  • 1
  • 10
  • 1
    Note the mmap() documentation requires the `length` to be a multiple of the system page size. 192*300 = 57600 which is not a multiple of the pagesize. Can you try with a value of 61440, which is the nearest page size ? i.e. you need to pad sizeof(showTechElementT)*MAX_SHOWTECH_NUM up to the neares page size , the pagesize is likely 4096 on your system. – nos Sep 27 '18 at 08:00
  • yes, pagesize is 4096, and I try with value 61440, still get the same error. potentially unexpected fatal signal 7. Bus error (core dumped) – jackxie Sep 27 '18 at 08:50

0 Answers0