runtime: MemoryMappedFile.CreateNew on macOS throws System.IO.PathTooLongException
Description
MemoryMappedFile.CreateNew throws a
System.IO.PathTooLongException: The specified file name or path is too long, or a component of the specified path is too long.
exception when passing in null as the map name (null mapName is required on
unix as noted in https://github.com/dotnet/runtime/issues/21863).
Program.cs:
using System.IO.MemoryMappedFiles;
// Passing null as mapNames are not supported for mmf on unix
using var mmf = MemoryMappedFile.CreateNew(null, 1);
When run, will throw:
dotnet run --project MemoryMapIssue
Unhandled exception. System.IO.PathTooLongException: The specified file name or path is too long, or a component of the specified path is too long.
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateSharedBackingObjectUsingMemory(MemoryMappedProtections protections, Int64 capacity, HandleInheritability inheritability)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateSharedBackingObject(MemoryMappedProtections protections, Int64 capacity, HandleInheritability inheritability)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(FileStream fileStream, String mapName, HandleInheritability inheritability, MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew(String mapName, Int64 capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, HandleInheritability inheritability)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew(String mapName, Int64 capacity)
at Program.<Main>$(String[] args) in /Users/aida/workspace/MemoryMapIssue/Program.cs:line 5
Configuration
- OS: macOS 12.1
- Arch: ARM64
dotnet --version
6.0.101
dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
dotnet --list-sdks
6.0.101 [/usr/local/share/dotnet/sdk]
Regression?
Unknown
Other information
Following guidance from https://github.com/dotnet/runtime/issues/21863 which
says unix systems do not support named mmf; so passing in null as name.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (11 by maintainers)
It looks like this is causing the FSharp Interactive pad in VSMac to crash on startup.
These (45) tests are failing on mono runtime as well -https://github.com/dotnet/runtime/issues/64947. These tests are currently disabled on iOS, MacCatalyst due to similar reason, so it’s not just osx-arm64 issue either.