question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`System.AccessViolationException` opening default aws-cdk fsharp template

See original GitHub issue

AWS-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:

  1. DotNet 6.0 (dotnet:0-6.0-bullseye)
  2. CDK version: cdk version 2.83.1 (build 006b542)
  3. 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:open
  • Created 3 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
baronfelcommented, Jun 11, 2023

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.

0reactions
chrissimon-aucommented, Jun 11, 2023

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fsc 4.0 Unhandled Exception: System. ...
Creating an empty F# class library in Visual Studio 2015 RC with F# 4 installed, and referencing the NuGet package Xaml.
Read more >
Autogenerate-Django-Models/data/programming_topics. ...
Learn how to take a scraped dataset and turn it into Django models using inspectdb. You can also use this method for legacy...
Read more >
CodeProject_1_SiteMap.xml
... /1259661/Elementary-Arithmetic-Generator-Excel-Template-for 2023-07-28 ... /1173686/A-Csharp-System-Tray-Application-using-WPF-Forms 2023-07-28 daily ...
Read more >
Angular template if else if
Angular template if else if. One frame. Mobile and desktop. In this tutorial, we will take a look at the ngIf directive. We...
Read more >
Axios body application/ x- www- form- urlencoded
I'm trying to do one with some form parameters that will be set. I'm using axios with the node server. I already have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found