malloc Assertion错误
来源:互联网 发布:斗鱼盛典 知乎 编辑:程序博客网 时间:2024/05/21 09:33
近日调试代码遇到了
malloc.c:3361: 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.
baidu一下,没有直接的说法。
采信了一种说法:代码已经内存越界把堆破坏了导致malloc失败
我做了一个实验,也验证了这个说法。
把一个全局数组增大到足够大,执行代码没有遇到错误;而采用较小的全局数组,执行代码会提示相同错误。
接下来,检查代码执行流,找到了一个memset语句。由于失误,memset的范围远大于目标应该被赋予的地址范围。
修正memset地址范围,问题解决。
可见,此类问题,一般都是内存访问越界导致。
0 0
- malloc Assertion错误
- malloc.c:3096: sYSMALLOc: Assertion 错误
- Debug Assertion failure错误
- Assertion failure 错误
- Assertion failure 错误
- 错误:Debug assertion failed
- vc 错误:Debug Assertion Failed
- Debug Assertion Failed 错误定位
- Debug Assertion Failed! 错误解析
- 抛出错误Debug Assertion Failed!
- Assertion
- Assertion failure in -[UITableView _endCellAnimationsWithContext:]---错误
- 错误: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
- Debug Assertion Failed错误如何消除
- 错误:Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexP
- C/C++出现Debug Assertion Failed!错误
- malloc时的错误
- malloc用法错误示例
- 小结(重新创建新的CRM组织)
- vc 文件版本获取
- 视音频编解码基本术语及解释
- SQL Server中的锁
- jQuery Mobile 页面过渡
- malloc Assertion错误
- 枚举符号链接
- Linked List Cycle - LeetCode
- 收到中软国际的电话面试(分享一下)
- 自由软件之“父”—Richard. M. Stallman
- EXTREME 设备操作手册
- PADS 覆铜(Copper Pouring)
- Java的内存泄漏
- AndroidManifest.xml file missing 的bug解决