Skip to content

17.11 VS hang in EndBuild #10709

@JanKrivanek

Description

@JanKrivanek

Context

VS hangs during solution close - turins out to be caused by hang in BuildManager.EndBuild
There are almost 3k cases hit in wild on 17.11

Analysis

Cab: https://watsonportal.microsoft.com/CabAnalysis?CabIdentifier=https://eaus2watcab01.blob.core.windows.net/global-202409/f1d6f9d9-57c1-47af-91c9-1973b6d19519.zip
Part of: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2254960

VS hanging due to BuildManager.EndBuild stuck waiting on the _noActiveSubmissionsEvent or _noNodesActiveEvent (not possible to distinguish due to release build optimizations).

image

Based on stacks the CancelAllSubmissionsAsync was called.
At the same time the InProcNode is still running:

image

Though based on the code it seems like we do not want to kill InProcNode in VS:

/// <summary>
/// Shutdown the inprocess node when the build finishes. By default this is false
/// since visual studio needs to keep the inprocess node around after the build finishes.
/// </summary>
public bool ShutdownInProcNodeOnBuildFinish
{
get => _shutdownInProcNodeOnBuildFinish;
set => _shutdownInProcNodeOnBuildFinish = value;
}

However it would mean that the node count (_activeNodes.Count) wouldn't reach zero and we wouldn't be able to signal the _noNodesActiveEvent:

private void CheckForActiveNodesAndCleanUpSubmissions()
{
Debug.Assert(Monitor.IsEntered(_syncLock));
if (_activeNodes.Count == 0)
{
var submissions = new List<BuildSubmissionBase>(_buildSubmissions.Values);
foreach (BuildSubmissionBase submission in submissions)
{
// The submission has not started do not add it to the results cache
if (!submission.IsStarted)
{
continue;
}
if (!CompleteSubmissionFromCache(submission))
{
submission.CompleteResultsWithException(new BuildAbortedException());
}
// If we never received a project started event, consider logging complete anyhow, since the nodes have
// shut down.
submission.CompleteLogging();
CheckSubmissionCompletenessAndRemove(submission);
}
_noNodesActiveEvent?.Set();
}
}

This feels unlikely - as it would hang always when we'd have InProcNode in VS.

Next steps in investigation

Debug through solution close in VS and find out if CheckForActiveNodesAndCleanUpSubmissions ever signals

Metadata

Metadata

Assignees

Labels

Area: PerformancePriority:1Work that is critical for the release, but we could probably ship withouttriaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions