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.
On Windows 11, files from a host bind mount exposed into Linux via
virtiofscannot be memory-mapped with shared read access.Normal file reads work, but
mmap(..., MAP_SHARED, PROT_READ)fails withENODEV(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 sbxrepro:
Using
MAP_PRIVATEinstead works. BothMAP_SHAREDandMAP_PRIVATEworks 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 indocker sbx,virtiofs,wslorMSBuild.