*** 检测到 glibc *** realloc(): 旧大小无效
realloc() 的问题。 我明白了 * glibc detectors * realloc(): invalid old size
void reallocatePtrTable(mmUctNode* nodeToReallocate){
int newSize = (nodeToReallocate->PtrTableCapacity)*INCREASE_FACTOR;
printf("(re)Allocating %p with %d bytes. ",nodeToReallocate->childPtrTable,sizeof(mmUctNode*)*newSize);
nodeToReallocate->childPtrTable=
(mmUctNode**)realloc(nodeToReallocate->childPtrTable,sizeof(mmUctNode*)*newSize);
printf(" Got %p\n",nodeToReallocate->childPtrTable);
if(!nodeToReallocate->childPtrTable){
puts("Re-allocation failed");
exit(-1);
}
}
我确保我没有重新分配空指针或错误指针。初始内存分配 由 malloc() 完成
(re)Allocating 0x8801fc8 with 480 bytes. Got 0x8807a98
(re)Allocating 0x8807a98 with 960 bytes. Got 0x880d2b8
(re)Allocating 0x880d2b8 with 1920 bytes. Got 0x8818290
(re)Allocating 0x8818290 with 3840 bytes. Got 0x882e310
(re)Allocating 0x882e310 with 7680 bytes. Got 0x885a410
(re)Allocating 0x885a410 with 15360 bytes. Got 0x88b9018
(re)Allocating 0x88b9018 with 30720 bytes. *** glibc detected *** /home/: realloc(): invalid old size: 0x088b9018 ***
Segmentation fault
Problems with realloc().
I get
* glibc detected * realloc(): invalid old size
void reallocatePtrTable(mmUctNode* nodeToReallocate){
int newSize = (nodeToReallocate->PtrTableCapacity)*INCREASE_FACTOR;
printf("(re)Allocating %p with %d bytes. ",nodeToReallocate->childPtrTable,sizeof(mmUctNode*)*newSize);
nodeToReallocate->childPtrTable=
(mmUctNode**)realloc(nodeToReallocate->childPtrTable,sizeof(mmUctNode*)*newSize);
printf(" Got %p\n",nodeToReallocate->childPtrTable);
if(!nodeToReallocate->childPtrTable){
puts("Re-allocation failed");
exit(-1);
}
}
I made sure I am not reallocating null or wrong pointers. Initial mem-allocation
is done by malloc()
(re)Allocating 0x8801fc8 with 480 bytes. Got 0x8807a98
(re)Allocating 0x8807a98 with 960 bytes. Got 0x880d2b8
(re)Allocating 0x880d2b8 with 1920 bytes. Got 0x8818290
(re)Allocating 0x8818290 with 3840 bytes. Got 0x882e310
(re)Allocating 0x882e310 with 7680 bytes. Got 0x885a410
(re)Allocating 0x885a410 with 15360 bytes. Got 0x88b9018
(re)Allocating 0x88b9018 with 30720 bytes. *** glibc detected *** /home/: realloc(): invalid old size: 0x088b9018 ***
Segmentation fault
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能不小心覆盖了 malloc 内部簿记数据,例如通过缓冲区溢出。通常这被称为“内存损坏”。
You probably accidentally overwrote mallocs internal book keeping data, for example through a buffer overflow. Generally this is known as "memory corruption".
你不能这样写:
你必须像这样声明临时指针:
然后:
You can't write like this:
you must declare temporary pointer like this:
and then: