Skip to content

runtime: use PAGE_NO­ACCESS in sysReseve #33327

Open
@alexbrainman

Description

@alexbrainman

Windows version of runtime.sysReseve calls VirtualAlloc with MEM_RESERVE and PAGE_READWRITE, but it should use PAGE_NO­ACCESS 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 Virtual­Alloc 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_NO­ACCESS.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions