What is the difference between a segmentation fault and a stack overflow?

Stack overflow is [a] cause, segmentation fault is the result.


At least on x86 and ARM, the “stack” is a piece of memory reserved for placing local variables and return addresses of function calls. When the stack is exhausted, the memory outside of the reserved area will be accessed. But the app did not ask the kernel for this memory, thus a SegFault will be generated for memory protection.

Leave a Comment