Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

c++ - What is a “memory stomp”?

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

a C++ program which is easily capable of stomping memory (something you probably have never even heard of if you were born in a managed code world.)

And in fact I have never heard of it!

So, what is this, a memory stomp, stomping memory? When does it occur?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...