中止核心倾倒

时间:2017-04-02 21:40:07

标签: c

stack.out: malloc.c:2372: 
sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1)- 1) * 2])) - 
__builtin_offsetof (struct malloc_chunk, fd)))) 
    && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) 
    && ((old_top)->size & 0x1) && ((unsigned long) old_end & pagemask) == 0)' failed.
Aborted (core dumped)

当我处理包含堆栈主题的代码时,突然看到我的gcc编译器错误我没有得到任何东西,这是什么意思,如果你知道这些东西,请在程序中告诉我错误。谢谢提前。

1 个答案:

答案 0 :(得分:2)

看起来你的堆内存已经损坏,可能是因为你在一些malloc()内存的末尾写得很好。使用gdb来获取函数调用的回溯,它们可以帮助您调试它。要获取程序的回溯,假设它被称为myProg,请输入以下内容:

gdb myProg
run

获得此异常后,键入:

bt

因为您可能会踩踏内存,所以发生错误的地方可能不是此回溯堆栈的一部分,但它是一个很好的起点。如果这没有帮助,那么使用valgrindmemwatch,两者都会被描述为here,这些工具会告诉您写入内存结束的位置,导致损坏,和核心转储。