Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omnisharp stops a few minutes after loading project #3485

Closed
3omar3allam opened this issue Dec 27, 2019 · 12 comments · Fixed by OmniSharp/omnisharp-roslyn#1707
Closed

Omnisharp stops a few minutes after loading project #3485

3omar3allam opened this issue Dec 27, 2019 · 12 comments · Fixed by OmniSharp/omnisharp-roslyn#1707

Comments

@3omar3allam
Copy link

Issue Description

Project works fine for a few minutes, then all omnisharp features stop working (intellisense and go-to reference, etc..).

Logs

OmniSharp log

[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
  at Microsoft.CodeAnalysis.Text.SourceText+LineInfo.get_Item (System.Int32 index) [0x0000f] in <ae0917f99a2140a190480a55c4fbf9ad>:0 
  at OmniSharp.Helpers.LocationExtensions.GetQuickFix (Microsoft.CodeAnalysis.Location location, OmniSharp.OmniSharpWorkspace workspace) [0x0007a] in <9a68c6cb5d34406fb639c5d426ef0d9e>:0 
  at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService+<>c__DisplayClass2_0.<Handle>b__2 (Microsoft.CodeAnalysis.Location l) [0x00000] in <9a68c6cb5d34406fb639c5d426ef0d9e>:0 
  at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00048] in <6f6cfe3dc7984568b6f7767c7378b138>:0 
  at System.Linq.Set`1[TElement].UnionWith (System.Collections.Generic.IEnumerable`1[T] other) [0x00018] in <6f6cfe3dc7984568b6f7767c7378b138>:0 
  at System.Linq.Enumerable+DistinctIterator`1[TSource].FillSet () [0x0000b] in <6f6cfe3dc7984568b6f7767c7378b138>:0 
  at System.Linq.Enumerable+DistinctIterator`1[TSource].ToArray () [0x00000] in <6f6cfe3dc7984568b6f7767c7378b138>:0 
  at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <6f6cfe3dc7984568b6f7767c7378b138>:0 
  at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0001e] in <6f6cfe3dc7984568b6f7767c7378b138>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList (Newtonsoft.Json.JsonWriter writer, System.Collections.IEnumerable values, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000e1] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000d4] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00079] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00253] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at OmniSharp.Protocol.Packet.ToString () [0x00000] in <1ed0cdfb5a5d42889b4f5df087ff7bd6>:0 
  at System.IO.TextWriter.WriteLine (System.Object value) [0x00028] in <285579f54af44a2ca048dad6be20e190>:0 
  at System.IO.TextWriter+SyncTextWriter.WriteLine (System.Object value) [0x00000] in <285579f54af44a2ca048dad6be20e190>:0 
  at (wrapper synchronized) System.IO.TextWriter+SyncTextWriter.WriteLine(object)
  at OmniSharp.Services.SharedTextWriter.ProcessWriteQueue () [0x0001d] in <1ed0cdfb5a5d42889b4f5df087ff7bd6>:0 
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in <285579f54af44a2ca048dad6be20e190>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <285579f54af44a2ca048dad6be20e190>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <285579f54af44a2ca048dad6be20e190>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <285579f54af44a2ca048dad6be20e190>:0 
  at System.Threading.ThreadHelper.ThreadStart () [0x00008] in <285579f54af44a2ca048dad6be20e190>:0 

Environment information

VSCode version: 1.41.1
C# Extension: 1.21.9

Mono Information OmniSharp using global mono :6.4.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.0.101 Commit: bc5f8df0f5

Runtime Environment:
OS Name: linuxmint
OS Version: 19
OS Platform: Linux
RID: linuxmint.19-x64
Base Path: /usr/share/dotnet/sdk/3.0.101/

Host (useful for support):
Version: 3.0.1
Commit: 19942e7199

.NET Core SDKs installed:
2.1.802 [/usr/share/dotnet/sdk]
2.2.402 [/usr/share/dotnet/sdk]
3.0.101 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
Angular-BeastCode Mikael 8.1.2
angular-console nrwl 10.0.0
angular-essentials johnpapa 0.6.3
Angular2 johnpapa 8.3.0
angular2-inline natewallace 0.0.17
auto-using Fudge 0.7.9
azure-bot Zim 0.0.4
csharp ms-vscode 1.21.9
cshtml fireside21 0.1.3
debugger-for-chrome msjsdiag 4.12.3
EditorConfig EditorConfig 0.14.4
gitlens eamodio 10.2.0
material-icon-theme PKief 3.9.2
mssql ms-mssql 1.8.0
ng-template Angular 0.900.3
prettier-standard-vscode numso 0.6.0
prettier-vscode esbenp 3.18.0
python ms-python 2019.11.50794
r Ikuyadeu 1.2.0
sqltools mtxr 0.21.5
team ms-vsts 1.161.0
tsimporter pmneo 2.0.1
vsc-prolog arthurwang 0.8.23
vscode-color anseki 0.4.5
vscode-eslint dbaeumer 2.0.11
vscode-icons vscode-icons-team 9.6.0
vscode-mysql formulahendry 0.4.0
vscode-npm-script eg2 0.3.10
vscode-nuget-package-manager jmrog 1.1.6
vscode-peacock johnpapa 3.2.0
vscode-sqlite alexcvzz 0.8.1
vscode-typescript-tslint-plugin ms-vscode 1.2.3
winteriscoming johnpapa 1.3.0
xml DotJoshJohnson 2.5.0
@3omar3allam 3omar3allam changed the title Omnisharp stops after a few minutes after loading project Omnisharp stops a few minutes after loading project Dec 27, 2019
@filipw
Copy link
Contributor

filipw commented Dec 27, 2019

can you please share the project that reproduces this issue? according to the stack trace it might be a bug in the compiler

@markmcgookin
Copy link

We are seeing this same issue, I can't post the project right now as it contains a lot of our proprietary code but I will try and recreate the issue with a clean sample project soon.

We have a dotnet core web api app, with a few projects, some are dotnet core 2.2 class libraries, but the issue only started after we upgraded the API to dotnet core 3.1 (and at the same time added a new dotnet core 3.1 project to the solution.... so it could be either)

For us I think the issue lies in the added project, not the upgrade of dotnet. The new project is a submodule, and it uses the Microsoft.NET.Sdk.Razor SDK type (all the others are either Sdk="Microsoft.NET.Sdk or Microsoft.NET.Sdk.Web) ... maybe that is the issue.

Opening the razor submodule on it's own seems to work ok, I thought it was because it was using a new format of "using" statement without brackets wrapping the using context, but on changing that to the traditional style, the problem is persisting.

@xtellurian
Copy link

xtellurian commented Feb 6, 2020

I had a similar issue.

I updated to the latest omnisharp-roslyn using "omnisharp.path": "latest" and the issue has resolved itself. I think my current (working) version is 1.34.11-beta.24

@xtellurian
Copy link

I take that back, I'm still seeing the issue.

@JoeRobich
Copy link
Member

@xtellurian Can share logs? Also do you have a project that will repo this behavior?

@xtellurian
Copy link

@JoeRobich Unfortunately for us in this situation, it's a closed source project. However, I think it has something to do with Razor pages.

The error seems non-deterministic, I have to open/ close files to make it occur, although it inevitably occurs.
It may occur when I open .cs files in an asp.net project with Razor Pages.
It seems to happen even with older versions of omnisharp-roslyn

The below logs have had paths and project names redacted.

OmniSharp log:

Starting OmniSharp server at 07/02/2020, 11:59:42 am
    Target: yyy/apps.sln

OmniSharp server started with Mono 6.8.0.
    Path: /Users/rian/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11-beta.24/omnisharp/OmniSharp.exe
    PID: 16512

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.15.3 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 16.3 - "/Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin"
            2: StandAlone 16.3 - "/Users/rian/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11-beta.24/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 16.3 - "/Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin"
            CscToolExe = csc.exe
            CscToolPath = /Users/rian/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11-beta.24/omnisharp/.msbuild/Current/Bin/Roslyn
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'yyy/apps'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'yyy/apps.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'xxx.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/rian/src/dev.azure.com/amphoradata/Amphora/apps'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: xxx.csproj
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'xxx/apps' on host 16454.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: xx.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'xxx.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'xxx.csproj'
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
  at Microsoft.CodeAnalysis.Text.SourceText+LineInfo.get_Item (System.Int32 index) [0x0000f] in <5a27fd083507435b81a01127fc008020>:0 
  at OmniSharp.Helpers.LocationExtensions.GetQuickFix (Microsoft.CodeAnalysis.Location location, OmniSharp.OmniSharpWorkspace workspace) [0x0007a] in <603c304251c74d09a39d8a403f846882>:0 
  at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService+<>c__DisplayClass2_0.<Handle>b__2 (Microsoft.CodeAnalysis.Location l) [0x00000] in <603c304251c74d09a39d8a403f846882>:0 
  at System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00048] in <b62ff15cbb8d435193cbdcd26f86d362>:0 
  at System.Linq.Set`1[TElement].UnionWith (System.Collections.Generic.IEnumerable`1[T] other) [0x00018] in <b62ff15cbb8d435193cbdcd26f86d362>:0 
  at System.Linq.Enumerable+DistinctIterator`1[TSource].FillSet () [0x0000b] in <b62ff15cbb8d435193cbdcd26f86d362>:0 
  at System.Linq.Enumerable+DistinctIterator`1[TSource].ToArray () [0x00000] in <b62ff15cbb8d435193cbdcd26f86d362>:0 
  at System.Linq.Buffer`1[TElement]..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x0000a] in <b62ff15cbb8d435193cbdcd26f86d362>:0 
  at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__3[TElement].MoveNext () [0x0001e] in <b62ff15cbb8d435193cbdcd26f86d362>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList (Newtonsoft.Json.JsonWriter writer, System.Collections.IEnumerable values, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000e1] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000d4] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00079] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00253] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <07e3893119a945b29a35e81930b1c8ad>:0 
  at OmniSharp.Protocol.Packet.ToString () [0x00000] in <d1c4448fc2e54bb08e466d2bf5c757ae>:0 
  at System.IO.TextWriter.WriteLine (System.Object value) [0x00028] in <f759957039b44a0190b1110fdfe3030f>:0 
  at System.IO.TextWriter+SyncTextWriter.WriteLine (System.Object value) [0x00000] in <f759957039b44a0190b1110fdfe3030f>:0 
  at (wrapper synchronized) System.IO.TextWriter+SyncTextWriter.WriteLine(object)
  at OmniSharp.Services.SharedTextWriter.ProcessWriteQueue () [0x0001d] in <d1c4448fc2e54bb08e466d2bf5c757ae>:0 
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in <f759957039b44a0190b1110fdfe3030f>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <f759957039b44a0190b1110fdfe3030f>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <f759957039b44a0190b1110fdfe3030f>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <f759957039b44a0190b1110fdfe3030f>:0 
  at System.Threading.ThreadHelper.ThreadStart () [0x00008] in <f759957039b44a0190b1110fdfe3030f>:0 

@xtellurian
Copy link

I'm working on a repro, but it's hard to nail down the issue...

@xtellurian
Copy link

@xtellurian
Copy link

@3omar3allam not sure if this is the same issue you're seeing... what do you think?

@filipw
Copy link
Contributor

filipw commented Feb 7, 2020

Thank, this is a good repro.

I had a quick look and the problem here is that here we fall out of bounds with the current implementation.

In this case the state is as follow:

  • location is SourceLocation(c:\code\repro-omnisharp-crash\Pages\Test.cshtml__bg__virtual.cs@116:40)"Stats"
  • mapped line span points to {c:\code\repro-omnisharp-crash\Pages\Test.cshtml: (143,39)-(143,44)}

So what we do wrong is that we try to fetch line with index 143 (as defined in Test.cshtml) out of Test.cshtml__bg__virtual.cs which only has 138 lines in this case. So we try to pick text from the wrong document. We should pick the path from mapped line span, locate that document in the workspace and use that to pick the text.

What's funny is that it mostly works because the lines are correct and the filepath returned too, just the text doesn't add up; however VS Code doesn't use the text - only lines and filepath. So this crashes only when the real CSHTML is longer than the generated file.

@filipw
Copy link
Contributor

filipw commented Feb 7, 2020

This bug applies to all mapped files by the way, not just Razor

@utillity
Copy link

utillity commented Jan 16, 2021

OmniSharp keeps crashing for me, too. After this error, IntelliSense etc. no longer works:

[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 2459,
  "Command": "/findusages",
  "Arguments": {
    "FileName": "c:\\DEV\\...\\Models\\Mapper.cs",
    "Line": 82,
    "Column": 47,
    "OnlyThisFile": true,
    "ExcludeDefinition": false
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 2459,
  "Command": "/findusages",
  "Running": true,
  "Success": false,
  "Message": "\"System.InvalidOperationException: Unexpected null\\r\\n   at Roslyn.Utilities.Contract.Fail(String message)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.MapToAppropriateSymbol(ISymbol symbol)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsCoreAsync>d__20.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsAsync>d__19.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__34.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__40.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__39.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService.<Handle>d__2.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Navigation\\\\FindUsagesService.cs:line 41\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<AggregateResponsesFromLanguageHandlers>d__18.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 227\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 131\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 215\"",
  "Body": null,
  "Seq": 46,
  "Type": "response"
}

The line in question is not anything complex:
grafik

OmniSharp: c:\Users....vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.30\OmniSharp.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants