dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.07k stars 4.04k forks source link

CodeLensCallbackListener.GetDocumentIdAndNodeAsync may throw ArgumentOutOfRangeException #44639

Open tmat opened 4 years ago

tmat commented 4 years ago

Integration tests in CI build logged an error in CodeLens service hub log: https://github.com/dotnet/roslyn/pull/44512/checks?check_run_id=714386342

05/27/2020 01:54:18 Coordinated Universal Time : Error : StreamJsonRpc.RemoteInvocationException: Specified argument was out of the range of valid values.
Parameter name: span
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__116`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServices.CodeLens.ReferenceCodeLensProvider.DataPoint.<GetDataAsync>d__12.MoveNext() in /_/src/VisualStudio/CodeLens/ReferenceCodeLensProvider.cs:line 155
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.CodeLens.Service.CodeLensServiceHubService.<GetDataAsync>d__22.MoveNext()
RPC server exception:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: span
      at Microsoft.CodeAnalysis.SyntaxNode.FindNode(TextSpan span, Boolean findInsideTrivia, Boolean getInnermostNodeForTie)
      at Microsoft.VisualStudio.LanguageServices.CodeLens.CodeLensCallbackListener.<GetDocumentIdAndNodeAsync>d__13.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
      at Microsoft.VisualStudio.LanguageServices.CodeLens.CodeLensCallbackListener.<GetReferenceCountAsync>d__10.MoveNext()

Added a workaround to CodeLensCallbackListener.GetDocumentIdAndNodeAsync, but the code needs to be reviewed to determine if the workaround is an appropriate fix or there is a deeper issue.

jmarolf commented 3 years ago

This appears to be related to why does clicking on References keep prompting me to dock a new window? (internal ticket: AzDO#1120410)