dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.91k stars 785 forks source link

Exception with MMapped Files + Rename + Ionide + macOS #14061

Closed cartermp closed 2 years ago

cartermp commented 2 years ago

Unclear if this is a bug, but it was thrown in FCS so I'm filing this here.

  1. Pull down the branch from here: https://github.com/honeycombio/honeycomb-opentelemetry-dotnet/pull/296
  2. Go to Routing.fs, line 53
  3. Rename endpoints to something else, like createEndpoints

Throws an error:

[08:02:34.415 ERR] [LSP] CodeLensResolve - Child operation failed for /Users/pcarter/repos/honeycomb-opentelemetry-dotnet/examples/aspnetcore-fsharp/Routing.fs
System.AggregateException: One or more errors occurred. (The specified file name or path is too long, or a component of the specified path is too long.)
 ---> 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 FSharp.Compiler.CodeAnalysis.ItemKeyStoreBuilder.TryBuildAndReset() in D:\a\_work\1\s\src\fsharp\service\ItemKey.fs:line 451
   at <StartupCode$FSharp-Compiler-Service>.$IncrementalBuild.TypeCheck@492-7.Invoke(Tuple`2 _arg11) in D:\a\_work\1\s\src\fsharp\service\IncrementalBuild.fs:line 548
   at FSharp.Compiler.BuildGraph.Bind@53-1.Invoke(T x) in D:\a\_work\1\s\src\fsharp\BuildGraph.fs:line 53
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 465
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
   --- End of inner exception stack trace ---
[Error - 8:02:46 AM] Request textDocument/rename failed.
  Message: One or more errors occurred. (The specified file name or path is too long, or a component of the specified path is too long.)
  Code: -32603 

Looks like it's the creation of the MMapped file that throws the exception, but maybe there's some additional checks or some kind of fallback that could happen so that a rename operation doesn't just fail.

A little unclear why a path would be too long, since my path isn't exactly long.

vzarytovskii commented 2 years ago

I think, that we don't use mmaped files for the source text normally (there's no need), however maybe FSAC passes the flag as true? But regardless, it's a bug/limitation (it seems that in the mmaped files API) and we should fix/workaround it.

T-Gro commented 2 years ago

Related to (and solveable via?) https://github.com/dotnet/runtime/issues/63240 and https://github.com/fsharp/FsAutoComplete/issues/939 .

According to the comments, should be fixed in dotnet7. @cartermp : I assume you were using dotnet 6, correct?

cartermp commented 2 years ago

Oh yay, yes, this is that underlying .NET 6 issue. Closing!

vzarytovskii commented 2 years ago

Oh yay, yes, this is that underlying .NET 6 issue. Closing!

Whew...don't have to fix anything...