Chapter 5. Memory Corruption Part I—Stacks

A memory corruption is one of the most intractable forms of programming error for two reasons. First, the source of the corruption and the manifestation might be far apart, making it difficult to correlate cause and effect. Second, symptoms appear under unusual conditions, making it hard to consistently reproduce the error.

Fundamentally, memory corruption occurs when one or both of the following are true.

• The executing thread writes to a block of memory that it does not own.

• The executing thread writes to a block of memory that it does own, but corrupts the state of that memory block.

To exemplify the first condition, consider this small application:

#include <windows.h>#define BAD_ADDRESS 0xBAADF00D ...

Get Advanced Windows Debugging now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.