views:

79

answers:

1

Can anyone explain insights about the difference between Stack corruption and Static corruption ?

A: 

Stack corruption is a memory corruption that is a result of an operation in your program e.g. an unbounded array copy results in overwriting elements located in stack (local variables, return address etc). As a result the program crashes or exhibits undefined behavior. Static corruption (I guess you mean corruption of static variables) is just when the variable takes an unexpected value due to some kind of programming error and results in transient bugs

thanks.. can you explain little more on corruption of static variable?
Akki
Static variable is a variable that exists through the whole program duration, regardless of where they are declared. This is because they are stored in the data segment of the program. So either your mean with you question some kind of corruption of the data segment (may be from an overflow of a static variable) or you are asking something simple. e.g 2 threads modifying a variable declared in a function without synchronization but because the variable is declared as static this is not a thread-safe operation and the variable contains an unexpected value
So what i extract from this is: Static corruption is build dependent depending upon the layout of the data segment for that particular code compiled, whereas stack corruption is independent of build because particular code will generate same stack all the time.Am I right in my understanding ?
Akki