`System.AccessViolationException` opening default aws-cdk fsharp template
See original GitHub issueAWS-CDK offers a (not officially supported) FSharp template.
When using this template and opening it in VSCode with Ionide, after restoring dependencies, opening FSharp files in the project doesn’t function (e.g. tooltips, hints), System.AccessViolationException
message can be found in the F#
output log and the extension appears to be crashed (from that point it doesn’t work for other .fs files even if they aren’t from the template).
Although the issue is occurring in VSCode the exception stacktrace appears to suggest an FSharp compiler issue.
Repro steps
Detailed repro steps are provided in a repo: https://github.com/chrissimon-au/fcs-AccessViolationException-repro
The commit history itemises the steps used to create the repository, and the README describes steps to reproduce the errors.
Expected behavior
FSharp files in the cdk template project should work like normal FSharp files with hover, hints, autocomplete, etc.
Actual behavior
No normal functions and System.AccessViolationException
exceptions in the log.
Known workarounds
See repro repo: https://github.com/chrissimon-au/fcs-AccessViolationException-repro#workarounds
Related information
All details are in the reproduction repository as it uses a vscode devcontainer:
- DotNet 6.0 (
dotnet:0-6.0-bullseye
) - CDK version: cdk version 2.83.1 (build 006b542)
- Reproduced with Ionide v7.5.4 (current release version) and v7.6.1 (current pre-release version)
The full error log is:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Buffer.Memmove(Byte ByRef, Byte ByRef, UIntPtr)
at System.IO.UnmanagedMemoryStream.WriteCore(System.ReadOnlySpan`1<Byte>)
at FSharp.Compiler.IO.MemoryMappedFileExtensions+MemoryMappedFile-TryFromByteMemory-Static@390.Invoke(System.IO.MemoryMappedFiles.MemoryMappedViewStream)
at FSharp.Compiler.IO.MemoryMappedFileExtensions.trymmf(Int64, Microsoft.FSharp.Core.FSharpFunc`2<System.IO.MemoryMappedFiles.MemoryMappedViewStream,Microsoft.FSharp.Core.Unit>)
at FSharp.Compiler.IO.MemoryMappedFileExtensions.MemoryMappedFile.TryFromByteMemory.Static(FSharp.Compiler.IO.ReadOnlyByteMemory)
at FSharp.Compiler.IO.ByteStorage.FromByteMemoryAndCopy(FSharp.Compiler.IO.ReadOnlyByteMemory, Boolean)
at FSharp.Compiler.AbstractIL.ILBinaryReader.seekReadManifestResources(ILMetadataReader, Boolean, FSharp.Compiler.IO.ReadOnlyByteMemory, PEReader, FSharp.Compiler.IO.ReadOnlyByteMemory)
at FSharp.Compiler.AbstractIL.ILBinaryReader.seekReadModule(ILMetadataReader, Boolean, PEReader, FSharp.Compiler.IO.ReadOnlyByteMemory, UInt16, System.Tuple`2<Int32,Int32>, Boolean, Boolean, Boolean, Boolean, Boolean, Microsoft.FSharp.Core.FSharpOption`1<ILPlatform>, Boolean, Int32, Int32, Int32, System.String, Int32)
at FSharp.Compiler.AbstractIL.ILBinaryReader.openMetadataReader(System.String, BinaryFile, Int32, System.Tuple`8<UInt16,System.Tuple`2<Int32,Int32>,Boolean,Boolean,Boolean,Boolean,Boolean,System.Tuple`5<Microsoft.FSharp.Core.FSharpOption`1<ILPlatform>,Boolean,Int32,Int32,Int32>>, PEReader, FSharp.Compiler.IO.ReadOnlyByteMemory, Microsoft.FSharp.Core.FSharpOption`1<PEReader>, Boolean)
at FSharp.Compiler.AbstractIL.ILBinaryReader.OpenILModuleReader(System.String, ILReaderOptions)
at FSharp.Compiler.CompilerImports+TcImports.OpenILBinaryModule(Internal.Utilities.Library.CompilationThreadToken, System.String, FSharp.Compiler.Text.Range)
at FSharp.Compiler.CompilerImports+TryRegisterAndPrepareToImportReferencedDll@2142-2.Invoke(ProjectAssemblyDataResult)
at FSharp.Compiler.BuildGraph+Bind@61-1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Invoke(System.__Canon)
at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Control.AsyncActivation`1<System.__Canon>, System.__Canon, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Microsoft.FSharp.Control.FSharpAsync`1<System.__Canon>>)
at Microsoft.FSharp.Control.Trampoline.Execute(Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Control.AsyncReturn>)
at Microsoft.FSharp.Control.AsyncPrimitives.StartWithContinuations[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Threading.CancellationToken, Microsoft.FSharp.Control.FSharpAsync`1<System.__Canon>, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpFunc`2<System.Runtime.ExceptionServices.ExceptionDispatchInfo,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpFunc`2<System.OperationCanceledException,Microsoft.FSharp.Core.Unit>)
at Microsoft.FSharp.Control.FSharpAsync.StartWithContinuationsUsingDispatchInfo[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Control.FSharpAsync`1<System.__Canon>, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpFunc`2<System.Runtime.ExceptionServices.ExceptionDispatchInfo,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpFunc`2<System.OperationCanceledException,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpOption`1<System.Threading.CancellationToken>)
at Microsoft.FSharp.Control.FSharpAsync.StartWithContinuations[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Control.FSharpAsync`1<System.__Canon>, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpFunc`2<System.Exception,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpFunc`2<System.OperationCanceledException,Microsoft.FSharp.Core.Unit>, Microsoft.FSharp.Core.FSharpOption`1<System.Threading.CancellationToken>)
at FSharp.Compiler.BuildGraph+GetOrComputeValue@365-5[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Invoke(Microsoft.FSharp.Core.Unit)
at FSharp.Compiler.BuildGraph+Bind@61-1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Invoke(System.__Canon)
at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Control.AsyncActivation`1<System.__Canon>, System.__Canon, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Microsoft.FSharp.Control.FSharpAsync`1<System.__Canon>>)
at System.Runtime.CompilerServices.RuntimeHelpers.DispatchTailCalls(IntPtr, Void (IntPtr, IntPtr, System.Runtime.CompilerServices.PortableTailCallFrame*), IntPtr)
at <StartupCode$FsAutoComplete-Core>.$CompilerServiceInterface+ParseAndCheckFileInProject@302-5.Invoke(Microsoft.FSharp.Control.AsyncActivation`1<Microsoft.FSharp.Core.FSharpResult`2<Microsoft.FSharp.Core.Unit,System.String>>)
at Microsoft.FSharp.Control.Trampoline.Execute(Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Control.AsyncReturn>)
at <StartupCode$FSharp-Core>.$Async+clo@208-16.Invoke(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
Issue Analytics
- State:
- Created 3 months ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
That’s ok, neither of those would have included the fixes I mention. The fixes would have been on our nightly branch, which we don’t have a public channel for so you have to build and install it yourself.
Yes - this is running on a Mac M2 - in a linux VSCode devcontainer - I’d be happy to setup a session to pair with someone if that would be helpful.
But based on your comments perhaps first I should test with dotnet 7 or 8 runtimes and also on another machine.