What is a “memory stomp”?

后端 未结 3 1640
青春惊慌失措
青春惊慌失措 2020-12-12 12:52

I just came across this blog post which mentions “stomping memory”:

a C++ program which is easily capable of stomping memory (something you prob

3条回答
  •  情书的邮戳
    2020-12-12 13:31

    Memory is "stomped" when a piece of code manipulates memory without realizing that another piece of code is using that memory in a way that conflicts. There are several common ways memory can be stomped.

    One is allocating, say, 100 bytes of memory but then storing something past the 100th address. This memory might be used to hold something completely different. This is particularly hard to debug because the problem will appear when something tries to access the victim that was stomped on, and the code that stomped on it may be totally unrelated.

    Another is accessing memory after it was freed. The memory may be allocated for another object. Again, the code that shows the problem may be related to the newly-allocated object that got the same address and unrelated to the code that caused the problem.

提交回复
热议问题