简体   繁体   English

此malloc错误的含义是什么? 损坏的顶部尺寸?

[英]What is the meaning of this malloc error? Corrupted top size?

I'm trying to initialize some values in couple of structs I created. 我正在尝试在我创建的几个结构中初始化一些值。 (the goal of the program is to simulate virtual memory) For some reason when i try to initalize pgTable[i].validFlag = 1 I get this error, (该程序的目标是模拟虚拟内存)由于某种原因,当我尝试初始化pgTable [i] .validFlag = 1时,出现此错误,

malloc(): corrupted top size, malloc():损坏的最大大小,

but not if I initialize it to 0. I thought this had something to go with me going off the end of my array but I don't see how that's possible. 但是如果我将其初始化为0则没有。我认为这与我离开数组末尾的过程有些关系,但我看不出这是怎么回事。

Can anyone tell me what I'm doing wrong? 谁能告诉我我在做什么错?

  int* memmory = malloc( sizeof( int ) * sizeVM * pageSize );
  struct TLBentry* tlb = malloc( sizeof(struct TLBentry) * sizeTLB );
  struct pageTableEntry* pgTable = malloc( sizeof(struct pageTableEntry) * sizeVM );

  for( int i = 0; i < sizeTLB; i++){
    tlb[i].virtualAddress = i;
    tlb[i].physicalAddress = i;
  }

  for( int i = 0; i < sizePM; i++){
    pgTable[i].dirty = 0;
    pgTable[i].validFlag = 1;
    pgTable[i].physicalAddress = i;
  }

  memSys->virtMem = memmory;
  memSys->tlb = tlb;
  memSys->pgTable = pgTable;

在分配sizeVM条目时,循环上升到sizePM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 究竟是什么导致 `malloc()` 失败并出现 `malloc(): 损坏的顶部大小` - what exactly causes `malloc()` to fail with `malloc(): corrupted top size` malloc():矩阵逆的最大大小损坏 - malloc(): corrupted top size for matrix inverse 在 function 调用上获取 Malloc() 损坏的最大尺寸 - Getting a Malloc() corrupted top size on function call 有 malloc(): 损坏的最大尺寸问题 - Having malloc(): corrupted top size issue Malloc for char** 导致顶部大小损坏 - Malloc for char** results in a corrupted top size 当我在它之前/之后使用 printf() 时,为什么“malloc():损坏的顶部大小”错误得到修复? - Why does "malloc(): corrupted top size" error get fixed when I have printf() before/after it? 有人可以帮我弄清楚为什么我收到错误 malloc(): corrupted top size - Could someone help me figure out why I am getting the error malloc(): corrupted top size malloc():将元素添加到动态列表时损坏的顶部大小 - malloc(): corrupted top size when adding an element to a dynamic list 使用 malloc 的 C 中的错误:大小损坏与 prev_size - error in C using malloc : corrupted size vs prev_size 为什么访问 function 中的结构成员会导致 malloc(): C 语言中的顶部大小损坏? - Why accessing structure members inside a function causes malloc(): corrupted top size in C language?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM