|
|
|
|
|
by astrange
842 days ago
|
|
> It segfaults on macOS because the runtime/OS has allocated the stack such that the overflow results in a bad memory access, but that is a behavior of the runtime/OS/hardware, not the language. Stack overflows are checked in C on macOS not because of guard pages but because the compiler emits stack checks (with cookies). Probably the same is true here. > I guarantee I could exploit this on a system that does not have virtual memory, or a runtime that does not have unmapped addresses at the end of the stack, to, say, manipulate the contents of another thread’s stack. Therefore, this behavior is undefined. That's implementation-defined, not undefined. |
|
Compiler-emitted stack checking is optional and not the default, and definitely not what is causing the crash here.
> That's implementation-defined, not undefined.
How could an implementation reasonably define the behavior for a stack overflow that silently corrupts another variable?