Question

Can this "overrun" condition ever occur? Or, the system guarantees that the stack and heap are two completely isolated areas in the process's virtual address space, so that access/manipulation done in the stack can never affect the heap and vice versa?

One specific scenario that I'd like to find out is whether it's possible for the process to corrupt its memory in such a way that causes the system to no longer correctly manage the stack or heap.

Here is a useful link I've found: What and where are the stack and heap?

Was it helpful?

Solution

I think before that would happen, the program would terminate on either a std::bad_alloc type error (heap) or a stack overflow type error (stack). The heap and stack exist separately, and the only way I could see them intersecting would be in one of the two conditions I mentioned above, either of which would cause the program responsible to crash.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top