堆腐败:可能是什么原因?

编程入门 行业动态 更新时间:2024-10-20 01:20:10
本文介绍了堆腐败:可能是什么原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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:

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

更多推荐

堆腐败:可能是什么原因?

本文发布于:2023-11-28 07:01:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641390.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:腐败

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!