An introduction to virtual memory
internalpointers.com
internalpointers.com
But in reality, `test` has side effects since it's dereferencing ecx, which causes a memory page access, and potentially trap. Compilers insert what look like pointless loops ("stack probes") for `alloca` because if you try to stack allocate multiple pages worth of memory at once and then read only the later bytes, you can skip over stack guard pages that the kernel uses to page in memory on-demand or crash the program if it could cause the stack to clash into the heap.
It's a really nice example of the "there's always something further down" type thinking you need for low-level stuff imo. This was from reading x86 disassembly, which is an advanced topic that 90%(?) of programmers never have to care about because it's so "low level"...until you have to start caring about virtual memory, or your kernel implementation details.
Go had a horrible, horrible bug due to an interaction with something related to this (stack clash mitigation), signal stacks, and the kernel vDSO shared object. https://marcan.st/2017/12/debugging-an-evil-go-runtime-bug/
And I don't care if they didn't come out and say it in the spec. If your program depends on overflowing the stack into other regions of memory you need to be taken out into the street and publicly dealt with as an example to others. That being said, I'm sure there's something about implementation defined behavior around exceeding the platform's max for automatic storage duration objects. If not I may try to sneak that into C2X, lol.
Silly autocorrect.
[1]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/ [2]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/cheri...