Skip to content

Add support for Windows virtual memory functions (VirtualAlloc, ...) #4187

Open
@yanchith

Description

@yanchith

Updated description

Virtual memory is something that high performance applications tend to do. I think it would be great if they had the ability to run their memory allocation test suites under miri.

#3605 already tracks changes to mmap such that we can do virtual memory things with it under miri.

On Windows, the API to deal with virtual memory is VirtualAlloc and VirtualFree:

VirtualAlloc(0, size, MEM_RESERVE, PAGE_READWRITE);  // reserve
VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE); // commit
VirtualFree(ptr, 0, MEM_RELEASE);                    // release

The minimal set relevant flags is MEM_RESERVE and MEM_COMMIT for VirtualAlloc; and MEM_RELEASE on VirtualFree. There is also MEM_DECOMMIT, which could be useful too.

https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc
https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree

TODO @yanchith Provide runnable example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-shimsArea: This affects the external function shimsA-windowsArea: affects only Windows targetsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions