Conversation

That is not what your article states. It states that _chkstk catches exceptions. Can you provide a source to that?
1
1
Neither does any catching, and both relies on the OS (MiCheckForUserStackOverflow) to do the catching and allocation
Image
1
Thinking that _chkstk catches anything, or that it directly allocates pages is a complete misunderstanding of how stack growing works. Stack pages are allocated by the kernel, whenever the guard pages are hit. Probing is necessary so that a single logical allocation can't skip 1/
1
1
over enough memory without touching anything that would result in an address past the guard pages. For small stack functions, it is not needed exactly because when they're called, the call instruction will touch the stack page when pushing the return address. 2/
1
1
Ultimately, it does not matter how one does the stack probe. Some do the allocation inside, some do it outside the probe function. Gcc can inline it too. You can also use your own probing function. It does not matter how the pages are touched, they just need to be written. 3/
1
1
The reason it does not matter is that the OS is doing the heavy lifting. All you need to care about is not skipping too much on the stack without touching the memory inbetween. 4/4
1
1
* just to clarify, two meanings of allocation are mentioned here: logical allocation (sub rsp) and page allocation (what the kernel is doing). Should be obvious which is referring to which.
While mixing these terms would be an understandable mistake, the statement that _chkstk catches exceptions (as written in the original article) is blatantly incorrect.
2
2
Show replies