分段错误,虽然内存是 malloc'd [重复]

问题描述 投票:0回答:0
   uint32_t *cc=malloc( 262144*(sizeof(uint32_t)) );
   if (cc==0) 
     printf("no mem"); 
   int c; 
   for(c=0;c<262144;c++) */
     cc[c]=0; ```

程序接收信号 SIGSEGV,分段错误。 0x00005555555552d2 in main () at main.c:21 21cc[c]=0; (gdb) p c 1 美元 = 266236



I've tried to use calloc, but to no avail, always crashes at the same offset.
c linux memory-management low-level
© www.soinside.com 2019 - 2024. All rights reserved.