0

I got a memory corruption on the heap when running my 32bit app on Windows 2008 server, 64bit, when I check the heap block which was corrupted, I found that the metadata of the heap block was not corrupted, but the user accessible part was corrupted (at lease the first 4 bytes were corrupted according to my analysis).

You know, there are a lot of possibilities that can lead to heap corrupt, memory overrun/underrun, use wild pointer, mismatch heap handler, use uninitialized memory etc.

But since the metadata and the first 4 bytes of user accessible part are adjacent parts. I think the possibility of memory overrun/under run is very low. Because if it is a memory overrun or under run, then it is very likely that the metadata will also be corrupted.

I am not sure whether my understanding is correct or not? Anyone can give me a hint here?

trincot
  • 317,000
  • 35
  • 244
  • 286
user1137890
  • 147
  • 1
  • 4
  • 11
  • Memory overrun can occur when using pointer arithmetic, and the actual amount of memory skipped when a pointer is incremented or decremented will depend on the size of the object its pointing to. So an overrun is not necessarily going to affect consecutive bytes unless the overrun is writing to e.g. all elements of an array. – Roger Rowland May 30 '13 at 04:54
  • Yes, you are right. Now my concern is the possibility. The FIRST few bytes of the user accessible part are corrupted while the metadata is not, I think the possibility of this is much lower compared to the possibility of both corrupted. What is your opinion? – user1137890 May 30 '13 at 07:27
  • Well, if it were *my* problem, I would resist the temptation to theorise too much and get stuck into a debugging session to find what is *actually* happening - there are too many variables here. – Roger Rowland May 30 '13 at 07:30

0 Answers0