dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 655 forks source link

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. #7119

Closed TrieBr closed 1 week ago

TrieBr commented 2 months ago

Type: Bug

Issue Description

Every time I open my project in local dev containers or Codespaces, the C# extensions crashes with this error (see logs below). It seems to work for the same repository locally on my MacBook. Both Stable and Pre-release C# extensions crash.

Steps to Reproduce

Open a c# project in Codespaces or Dev containers. I've not been able to make a minimal reproducable example, but the crash happens 100% of the time when opening my project.

Expected Behavior

C# Extension opens the project and works.

Actual Behavior

C# Extension crashes with a memory access violation and stops working.

Logs

C# log

``` [stderr] Fatal error. [stderr] System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.[stderr] [stderr] at System.Buffer.Memmove(Byte ByRef, Byte ByRef, UIntPtr)[stderr] [stderr] at System.IO.UnmanagedMemoryStream.WriteCore(System.ReadOnlySpan`1)[stderr] [stderr] at System.IO.UnmanagedMemoryStream.Write(Byte[], Int32, Int32)[stderr] [stderr] at System.IO.Stream.Write(System.ReadOnlySpan`1)[stderr] [stderr] at System.IO.StreamWriter.Flush(Boolean, Boolean)[stderr] [stderr] at System.IO.StreamWriter.Write(Char[], Int32, Int32)[stderr] [stderr] at Microsoft.CodeAnalysis.Text.LargeText.Write(System.IO.TextWriter, Microsoft.CodeAnalysis.Text.TextSpan, System.Threading.CancellationToken)[stderr] [stderr] at Microsoft.CodeAnalysis.Host.TemporaryStorageService.g__WriteToMemoryMappedFile|12_0(<>c__DisplayClass12_0 ByRef) at Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__13.MoveNext() [stderr] at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__13, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__13 ByRef) at Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__11.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__11, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__11 ByRef) at Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__12.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__12, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__12 ByRef) at Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__27.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__27, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__27 ByRef) at Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText.SaveAllAsync(Microsoft.CodeAnalysis.Collections.ImmutableSegmentedList`1>, System.Threading.CancellationToken) at Roslyn.Utilities.AsyncBatchingWorkQueue`1+<>c__DisplayClass2_0+<b__0>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Roslyn.Utilities.AsyncBatchingWorkQueue`1+<>c__DisplayClass2_0+<b__0>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d> ByRef) [stderr] at Roslyn.Utilities.AsyncBatchingWorkQueue`1+<>c__DisplayClass2_0[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__0(Microsoft.CodeAnalysis.Collections.ImmutableSegmentedList`1>, System.Threading.CancellationToken) at Roslyn.Utilities.AsyncBatchingWorkQueue`2+d__17[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Roslyn.Utilities.AsyncBatchingWorkQueue`2+d__17[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__17,Roslyn.Utilities.VoidResult> ByRef) at Roslyn.Utilities.AsyncBatchingWorkQueue`2[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].ProcessNextBatchAsync() [stderr] at Roslyn.Utilities.AsyncBatchingWorkQueue`2+<g__ContinueAfterDelayAsync|15_1>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.Utilities.AsyncBatchingWorkQueue`2+<g__ContinueAfterDelayAsync|15_1>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext(System.Threading.Thread) at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() [Error - 2:35:01 AM] Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring. Shutting down server. ```

C# LSP Trace Logs

Post the output from Output-->C# LSP Trace Logs here. Requires `dotnet.server.trace` to be set to `Trace`

Environment information

VSCode version: 1.89.1 C# Extension: 2.28.11 Using OmniSharp: false

Dotnet Information ``` .NET SDK: Version: 8.0.204 Commit: c338c7548c Workload version: 8.0.200-manifests.9f663350 Runtime Environment: OS Name: debian OS Version: 12 OS Platform: Linux RID: linux-x64 Base Path: /usr/share/dotnet/sdk/8.0.204/ .NET workloads installed: There are no installed workloads to display. Host: Version: 8.0.4 Architecture: x64 Commit: 2d7eea2529 .NET SDKs installed: 8.0.204 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download ```
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |csdevkit|ms-dotnettools|1.5.20|ms-dotnettools.csdevkit-1.5.20-linux-x64| |csharp|ms-dotnettools|2.28.11|ms-dotnettools.csharp-2.28.11-linux-x64| |vscode-dotnet-runtime|ms-dotnettools|2.0.5|ms-dotnettools.vscode-dotnet-runtime-2.0.5| |vscode-eslint|dbaeumer|2.4.4|dbaeumer.vscode-eslint-2.4.4| |vscode-pull-request-github|GitHub|0.88.1|github.vscode-pull-request-github-0.88.1|;

Extension version: 2.28.11 VS Code version: Code 1.89.1 (Universal) (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:14:24.611Z) OS version: Darwin arm64 23.4.0 Modes: Remote OS version: Linux x64 6.5.0-1018-azure Remote OS version: Linux arm64 6.6.12-linuxkit

System Info |Item|Value| |---|---| |CPUs|Apple M2 Max (12 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|3, 6, 7| |Memory (System)|64.00GB (0.10GB free)| |Process Argv|--crash-reporter-id f2175c6c-f802-4920-8a42-5dc749a961d3| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|Codespaces: cautious space computing-machine| |OS|Linux x64 6.5.0-1018-azure| |CPUs|Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (8 x 799)| |Memory (System)|31.33GB (27.49GB free)| |VM|0%| |Item|Value| |---|---| |Remote|Dev Container: Eau Claire One @ desktop-linux| |OS|Linux arm64 6.6.12-linuxkit| |CPUs|unknown (4 x 0)| |Memory (System)|39.85GB (25.61GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 tftest:31042121 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 vscaat:30438848 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 9c06g630:31013171 dvdeprecation:31040881 dwnewjupyter:31039675 ```
TrieBr commented 2 months ago

I confirmed it works in 2.10.28, 2.15.30, 2.18.16, 2.23.15. Broken in 2.28.11.

I've reverted 2.23.15. Razor syntax highlighting still doesn't work at all, but at least the whole LSP server doesn't crash and break regular .cs files too.

dibarbet commented 2 months ago

Formatting the exception from the logs

[stderr] Fatal error.
[stderr] System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
[stderr] at System.Buffer.Memmove(Byte ByRef, Byte ByRef, UIntPtr)
[stderr] at System.IO.UnmanagedMemoryStream.WriteCore(System.ReadOnlySpan`1)
[stderr] at System.IO.UnmanagedMemoryStream.Write(Byte[], Int32, Int32)
[stderr] at System.IO.Stream.Write(System.ReadOnlySpan`1)
[stderr] at System.IO.StreamWriter.Flush(Boolean, Boolean)
[stderr] at System.IO.StreamWriter.Write(Char[], Int32, Int32)
[stderr] at Microsoft.CodeAnalysis.Text.LargeText.Write(System.IO.TextWriter, Microsoft.CodeAnalysis.Text.TextSpan, System.Threading.CancellationToken)
[stderr] at Microsoft.CodeAnalysis.Host.TemporaryStorageService.g__WriteToMemoryMappedFile|12_0(<>c__DisplayClass12_0 ByRef) 
at Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__13.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__13, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__13 ByRef) 
at Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__11.MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.Host.TemporaryStorageService+d__11, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__11 ByRef) 
at Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__12.MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__12, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__12 ByRef) 
at Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__27.MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText+d__27, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__27 ByRef) 
at Microsoft.CodeAnalysis.RecoverableTextAndVersion+RecoverableText.SaveAllAsync(Microsoft.CodeAnalysis.Collections.ImmutableSegmentedList`1>, System.Threading.CancellationToken) 
at Roslyn.Utilities.AsyncBatchingWorkQueue`1+<>c__DisplayClass2_0+<b__0>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Roslyn.Utilities.AsyncBatchingWorkQueue`1+<>c__DisplayClass2_0+<b__0>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d> ByRef) [stderr]
at Roslyn.Utilities.AsyncBatchingWorkQueue`1+<>c__DisplayClass2_0[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__0(Microsoft.CodeAnalysis.Collections.ImmutableSegmentedList`1>, System.Threading.CancellationToken) 
at Roslyn.Utilities.AsyncBatchingWorkQueue`2+d__17[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext() 
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Roslyn.Utilities.AsyncBatchingWorkQueue`2+d__17[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__17,Roslyn.Utilities.VoidResult> ByRef) 
at Roslyn.Utilities.AsyncBatchingWorkQueue`2[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].ProcessNextBatchAsync() [stderr]
at Roslyn.Utilities.AsyncBatchingWorkQueue`2+<g__ContinueAfterDelayAsync|15_1>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext() 
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[Roslyn.Utilities.AsyncBatchingWorkQueue`2+<g__ContinueAfterDelayAsync|15_1>d[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Roslyn.Utilities.VoidResult, Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], Microsoft.CodeAnalysis.Workspaces, Version=4.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext(System.Threading.Thread) 
at System.Threading.ThreadPoolWorkQueue.Dispatch() 
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
[Error - 2:35:01 AM] Client Microsoft.CodeAnalysis.LanguageServer: connection to server is erroring. Shutting down server.

@TrieBr would you be able to enable crash dump collection by setting dotnet.server.crashDumpPath to a user writeable folder in vscode settings? That should hopefully create a crash dump. You can email the dump to me directly if you don't want to share publicly (dabarbet@microsoft.com) image

gabynevada commented 2 months ago

@dibarbet Did you receive the crash dump? I'm having the same issue, can generate the crash dump if needed.

dibarbet commented 2 months ago

@dibarbet Did you receive the crash dump? I'm having the same issue, can generate the crash dump if needed.

@gabynevada I haven't, if you have one please send it

dibarbet commented 2 months ago

Was able to reproduce today on a devcontainer, and figured out the issue thanks to https://github.com/dotnet/runtime/issues/79832

Issue appears to be our usage of memory mapped files - these files are getting stored in /dev/shm in the docker container which by default is given a max size of 64MB. We quickly exceed this value. Can view this in realtime via the command watch --interval=1 df --human-readable /dev/shm to see the usage of /dev/shm slowly go up to 100%, at which point the server crashes.

Currently exploring a fix for the issue, but in the meantime you can start the container with a larger /dev/shm size by passing --shm-size=4G to docker run (or adding "runArgs": ["--shm-size=4G"] to your devcontainer.json

ytimenkov commented 2 weeks ago

Amazing when someone has already solved your issue :) I had to reload VS Code every 2 minutes since language server was constantly crashing :(

As in dibarbet's comment I'm developing in containers.

mjrist commented 1 week ago

Running into the same issue here. Increasing the shm-size does work around the issue at least temporarily. It is unclear if the memory is ever freed though. It seems to continue to grow every time a solution is opened and Used never decreases.

dibarbet commented 1 week ago

It is unclear if the memory is ever freed though

The memory used here is likely not going to go away as long as the same solution is opened and the process is active. However I would expect it to fairly quickly hit a steady state and not increase.

mjrist commented 1 week ago

Every time we reload the solution (close solution followed by open solution on the same solution) it grows by about 6MB (probably a function of the solution being loaded - ours are typically large). I haven't seen it decrease.

We actually dynamically generate solutions so it is not uncommon for us to reload them.

In any case increasing the limit makes it unlikely for us to run out of space (developer is likely to reload vscode which resets the shm usage). Ideally it wouldn't leak memory though.

dibarbet commented 5 days ago

Will not be in this weeks prerelease, but should be in the one after.