提交 dff8c027 编写于 作者: M Manish Vasani

Handle null reference exception during analyzer execution when cancellation has been requested

Fixes VSO Watson [#763828](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/763828)
All the dumps for the watson show that cancellation was requested during analysis, leading to one thread clearing state while other thread faulted.
上级 1db69457
...@@ -1853,6 +1853,11 @@ private static void ComputeDeclarationsInNode(SemanticModel semanticModel, ISymb ...@@ -1853,6 +1853,11 @@ private static void ComputeDeclarationsInNode(SemanticModel semanticModel, ISymb
// Mark completion if we successfully executed all actions and only if we are analyzing a span containing the entire syntax node. // Mark completion if we successfully executed all actions and only if we are analyzing a span containing the entire syntax node.
if (success && analysisStateOpt != null && !declarationAnalysisData.IsPartialAnalysis) if (success && analysisStateOpt != null && !declarationAnalysisData.IsPartialAnalysis)
{ {
// Ensure that we do not mark declaration complete/clear state if cancellation was requested.
// Other thread(s) might still be executing analysis, and clearing state could lead to corrupt execution
// or unknown exceptions.
cancellationToken.ThrowIfCancellationRequested();
foreach (var analyzer in analysisScope.Analyzers) foreach (var analyzer in analysisScope.Analyzers)
{ {
analysisStateOpt.MarkDeclarationComplete(symbol, declarationIndex, analyzer); analysisStateOpt.MarkDeclarationComplete(symbol, declarationIndex, analyzer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册