简体   繁体   English

malloc.c:3074错误?

[英]malloc.c:3074 error?

When I write a C program, I encountered a problem that is as follows: 当我编写C程序时,遇到了如下问题:

malloc.c:3074: sYSMALLOc: Assertion (old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || malloc.c:3074:sYSMALLOc:声明(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. (((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)失败。

Please help me to fix it, thanks in advance! 请帮助我修复它,在此先感谢!

It seems like the administration kept for memory allocation has been corrupted. 似乎为内存分配保留的管理已损坏。 My guess would be that you have something like a buffer overflow somewhere before this error occurs. 我的猜测是在此错误发生之前,您在某处有缓冲区溢出之类的东西。

As the error is a result of an earlier problem (assuming I'm right), this can be a somewhat difficult problem to fix. 由于该错误是先前问题的结果(假设我是对的),因此修复起来可能会有些困难。 Perhaps a tool like valgrind can help you to detect incorrect writes to memory. 也许像valgrind这样的工具可以帮助您检测对内存的不正确写入。 If you have a small program that demonstrates the problem, I would suggest adding that code to your question. 如果您有一个演示该问题的小程序,建议您将该代码添加到您的问题中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM