Understanding Stack Overflow

Asked 2 months ago, Updated 2 months ago, 3 views

I think the stack will pile up from the larger memory address to the smaller memory address, but if it overflows, will the memory on the other side of the stack be rewritten?Or will the stack be rewritten in the direction in which the stack is growing, which is less than the stack limit?

memory-management stack

2022-09-30 11:18

1 Answers

Stacking toward smaller memory addresses

Not necessarily. Is there a case where the stack does not stack toward a lower address?

Are addresses less than the stack limit rewrites?

Well, that's usually the case.Modern CPU/OS has a memory protection mechanism, so you may not be able to rewrite itself outside of the stack (=doesn't break or break anything).

Assuming the stack goes from the 0x2000 address to a smaller address on a 16-bit CPU,

  • If the end of the stack (=minimum address) was a 0x1000, the stack overflow would destroy around the 0x0FFE address (=minimum address)
  • If the end of the stack was 0x0000, it would destroy (=destroy large addresses) around the 0xFFE address.

Well, there are both.So if you don't assume a specific processing system, everything will be fine.


2022-09-30 11:18

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.