You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NotSupportedException in memory-mapped-file optimization when copying ReadOnlyMemory into MemoryMappedFileViewStream #20263
While debugging the F# compiler in VS, the compiler crashes with a System.NotSupportedException when it tries to use the memory-mapped-file fast path for ReadOnlyMemory<byte> data.
The exception is:
This operation is not supported for an UnmanagedMemoryStream created from a SafeBuffer.
System.NotSupportedException
This operation is not supported for an UnmanagedMemoryStream created from a SafeBuffer.
[1] mscorlib.dll!System.IO.UnmanagedMemoryStream.PositionPointer.get
[2] FSharp.Compiler.Service.dll!FSharp.Compiler.IO.MemoryMappedFileExtensions.MemoryMappedFile-TryFromMemory-Static@392.Invoke
MemoryMappedFile.CreateViewStream(...) creates a stream backed by a SafeBuffer (the underlying mapped view). On .NET, accessing PositionPointer on that stream type is not supported and throws NotSupportedException.
The compiler optimization is assuming that the stream is a generic UnmanagedMemoryStream that supports PositionPointer, but this is not true for MemoryMappedFileViewStream.
Why this matters
This is a compiler bug in the memory-mapped-file optimization path, not a user code bug. It can fail while serializing compiler metadata/resources and prevents the compiler from completing the in-memory resource generation path.
Expected behavior
The code should copy the byte payload via the stream API (stream.Write) or another supported safe mechanism, without touching PositionPointer on a SafeBuffer-backed mapped view.
Additional context
Observed in the current debugging session inside the local repo:
C:\Users\Andrii\DevArchive\fsharp
branch: fix-project-options-async-debounce
repo: dotnet/fsharp
This appears to be in the compiler utility path used for metadata/resource pickling and memory-backed streaming.
changed the title [-]NotSupportedException in memory-mapped-file optimization when copying ReadOnlyMemory into MemoryMappedFileViewStream[/-][+]`NotSupportedException` in memory-mapped-file optimization when copying `ReadOnlyMemory` into `MemoryMappedFileViewStream`[/+]on Aug 15, 2026
Activity
[-]NotSupportedException in memory-mapped-file optimization when copying ReadOnlyMemory into MemoryMappedFileViewStream[/-][+]`NotSupportedException` in memory-mapped-file optimization when copying `ReadOnlyMemory` into `MemoryMappedFileViewStream`[/+]