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

Fix typing crash during open file analysis.

My previous PR #37303 to improve IDE open file analysis performance led to a functional regression where attempting to compute open file diagnostics for a partial type leads to recursive attempt to force complete all partial trees, which in turn attempt force completion of original tree. In presence of cancellation request, this leads to a stack overflow and VS crash. The fix here ensures that we don't attempt partial tree analysis when invoked in context of partial analysis itself.
Fixes VSO [#957250](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/957250) and [#957243](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/957243)
Fixes #37567

I have manually verified the crash before the fix and verified it does not repro after the fix. I am working on adding an integration test for the scenario with a follow-up commit/PR.
上级 ff431c22
......@@ -566,7 +566,7 @@ public async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsAsyn
return await GetAnalyzerSemanticDiagnosticsCoreAsync(model, filterSpan, analyzers, cancellationToken).ConfigureAwait(false);
}
private async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsCoreAsync(SemanticModel model, TextSpan? filterSpan, ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken)
private async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsCoreAsync(SemanticModel model, TextSpan? filterSpan, ImmutableArray<DiagnosticAnalyzer> analyzers, CancellationToken cancellationToken, bool forceCompletePartialTrees = true)
{
try
{
......@@ -588,7 +588,7 @@ private async Task<ImmutableArray<Diagnostic>> GetAnalyzerSemanticDiagnosticsCor
cancellationToken.ThrowIfCancellationRequested();
(ImmutableArray<CompilationEvent> compilationEvents, bool hasSymbolStartActions) = await ComputeAnalyzerDiagnosticsAsync(pendingAnalysisScope, getPendingEvents, taskToken, cancellationToken).ConfigureAwait(false);
if (hasSymbolStartActions)
if (hasSymbolStartActions && forceCompletePartialTrees)
{
await processPartialSymbolLocationsAsync(compilationEvents, analysisScope).ConfigureAwait(false);
}
......@@ -649,7 +649,7 @@ async Task processPartialSymbolLocationsAsync(ImmutableArray<CompilationEvent> c
Task.Run(() =>
{
var treeModel = _compilationData.GetOrCreateCachedSemanticModel(tree, _compilation, cancellationToken);
return GetAnalyzerSemanticDiagnosticsCoreAsync(treeModel, filterSpan: null, analysisScope.Analyzers, cancellationToken);
return GetAnalyzerSemanticDiagnosticsCoreAsync(treeModel, filterSpan: null, analysisScope.Analyzers, cancellationToken, forceCompletePartialTrees: false);
}, cancellationToken))).ConfigureAwait(false);
}
else
......@@ -658,7 +658,7 @@ async Task processPartialSymbolLocationsAsync(ImmutableArray<CompilationEvent> c
{
cancellationToken.ThrowIfCancellationRequested();
var treeModel = _compilationData.GetOrCreateCachedSemanticModel(tree, _compilation, cancellationToken);
await GetAnalyzerSemanticDiagnosticsCoreAsync(treeModel, filterSpan: null, analysisScope.Analyzers, cancellationToken).ConfigureAwait(false);
await GetAnalyzerSemanticDiagnosticsCoreAsync(treeModel, filterSpan: null, analysisScope.Analyzers, cancellationToken, forceCompletePartialTrees: false).ConfigureAwait(false);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册