Skip to content

VirtioFS bind mount on Windows returns ENODEV for mmap(MAP_SHARED), breaking .NET/MSBuild #55

@WillCodeForCash

Description

@WillCodeForCash

On Windows 11, files from a host bind mount exposed into Linux via virtiofs cannot be memory-mapped with shared read access.
Normal file reads work, but mmap(..., MAP_SHARED, PROT_READ) fails with ENODEV (No such device).

This fundamentally breaks .NET/MSBuild as it uses mmap to read the assemblies it compiles, and makes it impossible to build .NET applications under docker sbx

repro:

import mmap, os
fd = os.open('/c/path/to/some/mounted/file', os.O_RDONLY)
mmap.mmap(fd, 0, flags=mmap.MAP_SHARED, prot=mmap.PROT_READ)
$ python3 test_mmap.py
Traceback (most recent call last):
  File "/c/path/to/some/mounted/file", line 3, in <module>
    mmap.mmap(fd, 0, flags=mmap.MAP_SHARED, prot=mmap.PROT_READ)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 19] No such device

Using MAP_PRIVATE instead works. Both MAP_SHARED and MAP_PRIVATE works with normal docker bind mounts.

I can see that Rust had a similar issue and switched to using MAP_PRIVATE, but I am unsure whether this is actually an issue in docker sbx, virtiofs, wsl or MSBuild.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions