C Sysmalloc断言失败 [英] C Sysmalloc assertion failure

查看:244
本文介绍了C Sysmalloc断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行C程序时出现以下sysmalloc错误.

I am getting the below sysmalloc error in running a C program.

malloc.c:3096: 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.

使用int数组时,程序运行正常

The program works fine when using an int array

int(*M)[cnt] = malloc(sizeof(int[cnt][cnt]));

,但对于带符号的long int显示上述错误.该程序没有其他更改.

but is showing the above error for signed long int. There is no other change made in the program.

signed long int(*M)[cnt] = malloc(sizeof(signed long int[cnt][cnt])); 

可能是什么原因?当使用int数组时,这可以完美工作.因此,这里给出的内存管理应该不会有问题 C Malloc断言失败

What could be the reason? This worked perfectly when using an int array. Hence there shouldn't be a problem with memory management as given here C Malloc assertion failure

谢谢

推荐答案

此断言表达式看起来很合理,可以检查分配内部数据结构是否仍然完整.

This assertion expression looks like a sanity check to see if the allocation internal data structures are still intact.

此内部数据通常放置在分配的块之前和/或之后.如果出现问题,则意味着在malloc()之前执行的代码已在先前分配的块的边界之外写入.

This internal data is often placed before and/or after the allocated blocks. If something is wrong, it means that your code that executed before this malloc() has been writing outside the bounds of an earlier allocated block.

在Google中搜索Assertion (old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) -直接将我带到了.你不做谷歌搜索吗?

Doing a google search for Assertion (old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - directly led me to this. Didn't you do a google search?

这篇关于C Sysmalloc断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆