【发布时间】:2014-07-04 00:35:11
【问题描述】:
您很可能会看到此问题,因为您的问题已作为此问题的副本关闭。有关相关问题的完整列表,请参阅 Meta Stack Overflow 上的A long list of possible duplicates — C memory allocation and overrunning bounds。
示例问题
来自free char*: invalid next size (fast)noobie 于 2014-04-11 提出的问题。
我在连接过程后释放了char*,但收到此错误:
free(): invalid next size (fast): 0x0000000001b86170
这是我的代码:
void concat(stringList *list) {
char *res = (char*)malloc(sizeof(char*));
strcpy(res, list->head->string);
list->tmp = list->head->next;
while (list->tmp != NULL) {
strcat(res, ",");
strcat(res, list->tmp->string);
list->tmp = list->tmp->next;
}
printf("%s\n", res);
free(res);
}
一般问题
运行我的程序时,我看到如下错误消息:
*** glibc detected *** ./a.out: free(): corrupted unsorted chunks: 0x12345678 ***
详细信息可以在*** glibc detected ***和程序名称之后包含以下任何内容,并且消息后跟一个十六进制地址(显示为0x12345678)和另一个***:
free(): corrupted unsorted chunks: 0x12345678free(): invalid next size (fast): 0x12345678free(): invalid next size (normal): 0x12345678free(): invalid pointer: 0x12345678free(): invalid size: 0x12345678malloc(): corrupted unsorted chunks: 0x12345678malloc(): corrupted unsorted chunks 2: 0x12345678malloc(): memory corruption: 0x12345678malloc(): memory corruption (fast): 0x12345678malloc(): smallbin double linked list corrupted: 0x12345678munmap_chunk(): invalid pointer: 0x12345678realloc(): invalid next size (fast): 0x12345678realloc(): invalid old size (fast): 0x12345678realloc(): invalid pointer: 0x12345678corrupted double-linked list: 0x12345678
这发生在调用frobnicate() 函数时;那个函数有什么问题?
【问题讨论】:
-
我明白了这个意图,但目标用户不会找到这个。
-
@self.: 请看meta.stackoverflow.com/questions/254782