Corruption of the heap: what could be the cause?
source link: https://www.codesd.com/item/corruption-of-the-heap-what-could-be-the-cause.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Corruption of the heap: what could be the cause?
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.
Platform: Windows XP
Language: C++
Compiler: VC6
Thanks in advance
Common scenarios include:
- 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)
[EDIT] From the comments, a few more:
- Mixing new [] and new with delete [] and delete
- Missing or incorrect copy-constructors
- Pointer pointing to garbage
- Calling delete multiple times on the same data
- Polymorphic baseclasses without virtual destructors
Related Articles
Memory allocation / heap corruption in the constructor std :: string
Heap corruption in the MFC program
What could delay the preemption of a VxWorks task?
What could be the risk of fork execution over and over?
What could be the reason why this kind of Azure website hangs?
What could result in the use of hashtags and html5 mode not?
What could be the data type for the column having weblinks
Array_diff does not work as expected? What could be the reason?
What could decrease the performance of MySqls?
What could result in the absence of CKEditor icons?
The dynamic query runs directly but not by variable, what could be the reason?
What could be the reason why GWT mobile applications do not really work on a mobile device?
What could be done to retrieve the old values in the table after executing any update requests?
What could happen if the initialization of the copy list allowed explicit constructors?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK