I recently used the [`/FAsu` Visual C++ compiler option][1] to output the source + assembly of a particularly long member function definition. In the assembly output, after the stack frame is set up, there is a single call to a mysterious `_chkstk()` function.
The MSDN page on [`_chkstk()`][2] does not explain the reason why this function is called. I have also seen the Stack Overflow question [Allocating a buffer of more a page size on stack will corrupt memory?][3], but I do not understand what the OP and the accepted answer are talking about.
What is the purpose of the `_chkstk()` CRT function? What does it do?
[1]: http://msdn.microsoft.com/en-us/library/367y26c6.aspx
[2]: http://msdn.microsoft.com/en-us/library/ms648426.aspx
[3]: https://stackoverflow.com/q/4123609/196844 My guess (after reading your links) is that the function sets up protection so writes just outside the functions stack will be caught by the CRT, and can be handled like throwing exceptions in C++ or other things.
以上就是What is the purpose of the _chkstk() function?的详细内容,更多请关注web前端其它相关文章!