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.04k stars 4.03k forks source link

VS crash after closing solution #18864

Closed IlyaBiryukov closed 7 years ago

IlyaBiryukov commented 7 years ago

Version Used: VS: vsuvscore 2418.04 MS.CodeAnalysis.Features: 2.03.0.61515

Steps to Reproduce: It doesn't happen all the time

  1. Open solution in LSL mode
  2. Close the solution
  3. Open the solution again
  4. Expand a project within a solution folder
  5. Click 'Save All' button
  6. Close solution

Expected Behavior: VS does not crash

Actual Behavior: VS crashes

Stack Trace

[Worker Thread]
 Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.ErrorReporting.FatalError.Report
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.GetOrDefaultAsync<Microsoft.CodeAnalysis.Document, object>
 [Native to Managed Transition]
 mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess Line 184
 mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification Line 157
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.GetOrDefaultAsync<Microsoft.CodeAnalysis.Document, object>
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.Start<Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.<GetOrDefaultAsync>d__33<Microsoft.CodeAnalysis.Document, object>> Line 471
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.GetOrDefaultAsync<Microsoft.CodeAnalysis.Document, object>
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.RunAnalyzersAsync<Microsoft.CodeAnalysis.Document>
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.<RunAnalyzersAsync>d__31<Microsoft.CodeAnalysis.Document>> Line 316
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.RunAnalyzersAsync<Microsoft.CodeAnalysis.Document>
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.ProcessDocumentAnalyzersAsync
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.<ProcessDocumentAnalyzersAsync>d__30> Line 316
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.ProcessDocumentAnalyzersAsync
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.ProcessDocumentAsync
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.<ProcessDocumentAsync>d__31> Line 316
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.ProcessDocumentAsync
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.ExecuteAsync
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.<ExecuteAsync>d__18> Line 316
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.ExecuteAsync
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.IdleProcessor.ProcessAsync
 mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext Line 1090
...
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult Line 379
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.NormalPriorityProcessor.ExecuteAsync
 mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext Line 1090
...
 mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetResult Line 638
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.AbstractPriorityProcessor.WaitForHigherPriorityOperationsAsync
 mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext Line 1090
...
 mscorlib.dll!System.Threading.Tasks.TaskCompletionSource<System.__Canon>.SetResult Line 321
 Microsoft.CodeAnalysis.Features.dll!Microsoft.CodeAnalysis.SolutionCrawler.GlobalOperationAwareIdleProcessor.OnGlobalOperationStopped
 Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Notification.GlobalOperationNotificationService.RaiseGlobalOperationStopped.AnonymousMethod__1
 Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.EventMap.Registry<System.__Canon>.Invoke
 Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.EventMap.EventHandlerSet<System.EventHandler<Microsoft.CodeAnalysis.Notification.GlobalOperationEventArgs>>.RaiseEvent
 Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.Notification.GlobalOperationNotificationService.RaiseGlobalOperationStopped.AnonymousMethod__0
 Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.TaskExtensions.ContinueWithAfterDelay.AnonymousMethod__1
 Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.TaskExtensions.SafeContinueWith.AnonymousMethod__0
 Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.TaskExtensions.SafeContinueWith.AnonymousMethod__0
 mscorlib.dll!System.Threading.Tasks.ContinuationResultTaskFromTask<bool>.InnerInvoke Line 111

Debug Output

System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>DefaultDomain</AppDomain><Exception><ExceptionType>System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Unexpected false</Message><StackTrace>   at Roslyn.Utilities.Contract.ThrowIfFalse(Boolean condition, String message)
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.AbstractProjectCodeModel.GetCodeModelCache()
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.AbstractProjectCodeModel.TryGetCachedFileCodeModel(String fileName, ComHandle`2&amp;amp; fileCodeModelHandle)
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.CodeModelIncrementalAnalyzerProvider.Analyzer.FireEvents(DocumentId documentId, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.CodeModelIncrementalAnalyzerProvider.Analyzer.AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.&amp;lt;&amp;gt;c__DisplayClass30_0.&amp;lt;ProcessDocumentAnalyzersAsync&amp;gt;b__0(IIncrementalAnalyzer a, Document d, CancellationToken c)
   at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.&amp;lt;&amp;gt;c__DisplayClass31_1`1.&amp;lt;&amp;lt;RunAnalyzersAsync&amp;gt;b__0&amp;gt;d.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.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.&amp;lt;GetOrDefaultAsync&amp;gt;d__33`2.MoveNext()</StackTrace><ExceptionString>System.InvalidOperationException: Unexpected false
   at Roslyn.Utilities.Contract.ThrowIfFalse(Boolean condition, String message)
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.AbstractProjectCodeModel.GetCodeModelCache()
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.AbstractProjectCodeModel.TryGetCachedFileCodeModel(String fileName, ComHandle`2&amp;amp; fileCodeModelHandle)
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.CodeModelIncrementalAnalyzerProvider.Analyzer.FireEvents(DocumentId documentId, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.CodeModelIncrementalAnalyzerProvider.Analyzer.AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.&amp;lt;&amp;gt;c__DisplayClass30_0.&amp;lt;ProcessDocumentAnalyzersAsync&amp;gt;b__0(IIncrementalAnalyzer a, Document d, CancellationToken c)
   at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.&amp;lt;&amp;gt;c__DisplayClass31_1`1.&amp;lt;&amp;lt;RunAnalyzersAsync&amp;gt;b__0&amp;gt;d.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.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.&amp;lt;GetOrDefaultAsync&amp;gt;d__33`2.MoveNext()</ExceptionString></Exception></TraceRecord>

Dump

IlyaBiryukov commented 7 years ago

Dump in \\vspfs3\public\ilbiryuk\18864

Pilchie commented 7 years ago

tagging @heejaechang

heejaechang commented 7 years ago

@tmeschter isn't this the issue you looked before?

tmeschter commented 7 years ago

@heejaechang Yes it is. The vsuvscore 24618.04 build does not have the fix.

jasonmalinowski commented 7 years ago

Fixed by #17893 then.