3

Corruption of the heap: what could be the cause?

 2 years ago
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?

advertisements

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

I have some trouble with memory allocation again and I can't figure out why. When I run the program in debug mode I recieve the following error message (I tried to translate it as accurately as possible): Windows has triggered a breakpoint in LogoCol

Heap corruption in the MFC program

I am having a problem with a heap corruption issue in a program. In the program I am reading a block of data and performing FFT and IFFT on it. I am doing it for 2 images, master and slave. The EXACT same code works fine for the master but shows a he

What could delay the preemption of a VxWorks task?

In my current project, I have two levels of tasking, in a VxWorks system, a higher priority (100) task for number crunching and other work and then a lower priority (200) task for background data logging to on-board flash memory. Logging is done usin

What could be the risk of fork execution over and over?

I have a program that execute fork many time sequentially (and not at the same time). What could be the risk of a such behaviour. Because some times I get a fork error after execution fork many timesThe Open Group Base Specifications Issue 7, IEEE St

What could be the reason why this kind of Azure website hangs?

I have a rather high-load deployment on Azure: 4 Large instances serving about 300-600 requests per second. Under normal conditions: "Average Response Time" is 70 to 150ms, but sometimes it may grow up to 200-300ms, but it's absolutely OK. Thoug

What could result in the use of hashtags and html5 mode not?

Assuming you have <a href="#/sign-in">Link</a> and it works fine out of the box with $routeProvider in your config, what could cause enabling html5 mode to not work? Assuming you have <base href="/" set in the head and r

What could be the data type for the column having weblinks

One curious question. if i have a table with column with weblinks then what could be the datatype nvarchar or varchar. and what could be the size of that datatype?I'd say varchar(1000) would be enough (unless you're going to store some Amazon URLs, o

Array_diff does not work as expected? What could be the reason?

I have two arrays . Check the code $array1 = array(0=>'215',1=> '225'); $array2 = array(0=>'225'); $diff_result = array_diff($array1, $array2); $diff = array_values($diff_result); print_r($array1);echo "<br>"; print_r($array2);ech

What could decrease the performance of MySqls?

Basically we are very happy with Mysqls performance, similar queries are completed in a split second. Now we face a problem with this query SELECT dc.id,dmr.art_id FROM dmr JOIN dma ON dma.id = dmr.dml_id JOIN dc ON dc.id = dma.dc_id WHERE dmr.art_id

What could result in the absence of CKEditor icons?

When the browser is IE9 and it has a horizontal scrollbar, sometimes icons go missing from my CKEditor. This happens especially during Undo and when switching between source mode and back. The horrible part is that I can't replicate it outside my sit

The dynamic query runs directly but not by variable, what could be the reason?

Here is my scenario, I'm creating a dynamic query using a select statement which uses functions to generate the query. I am storing it into a variable and running it using exec. i.e. declare @dsql nvarchar(max) set @dsql = '' select @dsql = @dsql + d

What could be the reason why GWT mobile applications do not really work on a mobile device?

what could be the reason for that, that gwt mobile apps doesnt really work on mobile phone? iam using a ZTE-Blade Android 2.1 (in germany Base Lutea) mobile phone and i have big problems with gwt-mobile-apps while using this mobile phone. the gwt-app

What could be done to retrieve the old values ​​in the table after executing any update requests?

What could be done to get the old values back in the table after execution of any update query on it ? I am using PHP and Mysql DBBy default: nothing. There is no way. Unless maybe: You were in a transaction (used BEGIN) and did not yet COMMIT. You c

What could happen if the initialization of the copy list allowed explicit constructors?

In the C++ standard, §13.3.1.7 [over.match.list], the following is stated: In copy-list-initialization, if an explicit constructor is chosen, the initialization is ill-formed. This is the reason why we can't do, for example, something like this: stru

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK