Repository navigation
Description
Problem
The Windows mmap provider ignores prot and flags and always calls VirtualAlloc with PAGE_READWRITE. A caller asking for PROT_READ gets writable pages. Unknown/incompatible flag bits are silently accepted.
Starting points: std/sys/windows/memory.wave.
Reproduction
Source audit at 4c3372157d8889fa8bbef0a7ccd2e72aab1c5c6c plus an executed Linux-hosted O0/O2 boundary mock. The unchanged provider body was compiled after adapting only extern(system, ...) to extern(c, ...).
Call mmap(null, 16, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) and record VirtualAlloc's fourth argument. It is 4 (PAGE_READWRITE), not 2 (PAGE_READONLY), at both optimization levels. The prot and flags arguments are never inspected. No native Windows execution was performed.
Scope
Implement the supported anonymous private mapping contract and reject unsupported requests before allocation. Use the existing null failure convention. This concerns public mmap; ordinary sys_alloc remains a read/write allocator. Windows protection constants distinguish PAGE_READONLY (2) from PAGE_READWRITE (4).
Difficulty: medium.
Completion criteria
- Supported protections are passed accurately to VirtualAlloc.
- Unsupported protection/flag combinations fail explicitly without allocating.
- Test forwarding and rejection without deliberately crashing the test process; verify native behavior on Windows amd64/ARM64.
- Keep sys_alloc/sys_free and existing callers working.
Activity