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.

Omnisharp stops a few minutes after loading project

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
filipwcommented, 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.

0reactions
utillitycommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

When VSCode/OmniSharp Stop Working
I've run into issues a couple of times now when working in Visual Studio Code where OmniSharp seems to lose itself.
Read more >
Omnisharp silently crashes when working with docker
It will work for a few seconds and after that stick me with 180+ "problems", all of which are false (the app works..)...
Read more >
Omnisharp server timing out on load : r/vscode
Hi r/vscode , Omnisharp tries to start the server and basically just hangs until it times out. Increasing timeout time doesn't seem to...
Read more >
Intellisense not working for Visual Studio Code
I make a new project, after OmniSharp loads in VSCode. The packages don't highlight correctly, and I don't have intellisense.
Read more >
Unable to start OmniSharp in JetBrains Rider - SonarCloud
When you look at the SonarLint log tab, can you determine if the OmniSharp process is “stuck” or is there some work going...
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