Naveen Naveen - 1 month ago 6
C++ Question

Stack corruption in C++

In C++, in which way the stack may get corrupted. One way I guess is to overwriting the stack variables by accessing an array beyond its boundaries. Is there any other way that it can get corrupted?

Answer
  1. You could have a random/undefined pointer that ends up pointing to the stack, and write though that.
  2. An assembly function could incorrectly setup/modify/restore the stack
  3. Cosmic waves could flips bits in the stack.
  4. Radioactive elements in the chip's casing could flip bits.
  5. Anything in the kernel could go wrong and accidentally change your stack memory.

But those are not particular to C++, which doesn't have any idea of the stack.

Comments