堆腐败:可能是什么原因? [英] Heap corruption: What could the cause be?

查看:85
本文介绍了堆腐败:可能是什么原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调查由于堆损坏而导致的崩溃.由于这个问题并不重要,并且涉及分析堆栈和转储结果,因此我决定对与崩溃相关的文件进行代码审查.

I am investigating a crash due to heap corruption. As this issue is non-trivial and involves analyzing the stack and dump results, I have decided to do a code review of files related to the crash.

坦率地说,我对何时损坏堆没有深入的了解.

To be frank, I don't have in-depth knowledge of when the heap could be corrupted.

如果您能提出可能导致堆损坏的方案,我将不胜感激.

I would appreciate if you could suggest scenarios which could lead to heap corruption.

平台: Windows XP

语言: C ++

编译器: VC6

推荐答案

常见方案包括:

  • 在数组分配的空间(char *stuff = new char[10]; stuff[10] = 3;)之外写入
  • 投射到错误的类型
  • 未初始化的指针
  • ->和.
  • 的拼写错误
  • 使用*和&时出现拼写错误(或二者之一)
  • Writing outside the allocated space of an array (char *stuff = new char[10]; stuff[10] = 3;)
  • Casting to the wrong type
  • Uninitialized pointers
  • Typo error for -> and .
  • Typo error when using * and & (or multiple of either)

在评论中,还有更多内容:

From the comments, a few more:

  • 混合新的[]和新的删除[]并删除
  • 缺少或不正确的复制构造函数
  • 指向垃圾的指针
  • 多次调用删除同一数据
  • 没有虚拟析构函数的多态基类

这篇关于堆腐败:可能是什么原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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