Description
Windows version of runtime.sysReseve calls VirtualAlloc with MEM_RESERVE and PAGE_READWRITE, but it should use PAGE_NOACCESS when using MEM_RESERVE.
According to https://devblogs.microsoft.com/oldnewthing/20171227-00/?p=97656
Why do you have to pass a valid value even if the system doesn’t use it?
This is an artifact of how the front-end parameter validation is done. The VirtualAlloc function does parameter validation by checking each parameter individually to confirm that the value is among the valid values.
and in particular
Bonus chatter: You would think that the flProtect would not be used when reserving address space with MEM_RESERVE, but you’d be wrong. If reserving regular address space, then the protection should be PAGE_NOACCESS.
Someone would have to try and see what effect this change have on memory used by Go executable before making this change. Maybe by using vmmap or rammap tools.
I am creating this issue before I forget.
/cc @aclements and @zx2c4 because you might be interested.
Alex