3 ms·
> touch a byte every 4KB in the direction of stack growth before you use bulky stack allocations. I have a macro for this somewhere. > you need to touch a byte
by Joker_vD 5y ago
> touch a byte every 4KB in the direction of stack growth before you use bulky stack allocations. I have a macro for this somewhere.
> you need to touch a byte ever guard-page-size bytes (in the direction of stack growth) in large stack allocations before using those allocations
> Also, the compiler could (and arguably should) generate code to do this touching of a byte every guard-size-bytes thing for dynamically sized stack allocations, which would make the problem disappear.
That's precisely what MSVC does since 1995 or so: inserting the calls to the _chkstk() function that touches the guard pages. I believe gcc also does this when it targets Windows.
- cryptonector 5y agoExcellent. Thanks for the tip. Some references: https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-chkstk https://docs.microsoft.com/en-us/windows/win32/devnotes/-win... https://metricpanda.com/rival-fortress-update-45-dealing-with-__chkstk-__chkstk_ms-when-cross-compiling-for-windows/ https://metricpanda.com/rival-fortress-update-45-dealing-wit...