Most operating systems and standard libraries have checks and countermeasures to make this a lot harder nowadays, but still.
Most operating systems and standard libraries have checks and countermeasures to make this a lot harder nowadays, but still.
I actually don't know where it came from. It was true in original PDP-11 Unix for sure: you had the program text followed by a grows-up heap, with the grows-down stack placed at the top of the program segment. Interestingly PDP-11 addressing was general enough to have implemented a grows-up stack, so this is clearly a mistake Unix could have corrected. I just don't know if this was the original use of the convention or if it inherited it from elsewhere.
The 8080 had 64KB address space. I bet the rationale was to partition memory so that classic memory usage goes upwards from 0000 to FFFF and the stack goes downwards from FFFF to 0000. This removes the need to define a boundary between the two beforehand.
Of course this is totally speculation on my part, I might be super wrong.
Independently the 6502 also had a downward stack. I think the only modern machine with am upward-growing stack is the HP PA-RISC.
[1] https://www.unibw.de/patch/papers/usenixsecurity20-wasm.pdf