// HACKER NEWS — CYBERSECURITY
How do functions like alloca allocate memory from the stack?
A little while ago, I talked about how compilers ensure that large stack allocations do not skip over the guard page. Shawn Van Ness was curious how this works with _alloca. “Does it do the necessary _chkstk() probing?”
Yes, the _alloca() function calls the same _chkstk() function to probe the stack before adjusting the stack pointer for the allocated memory.
Observe that the same __chkstk function is used both for performing the initial stack probe when creating the local frame as well as for the alloca().