-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
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).
Based on stacks the CancelAllSubmissionsAsync was called.
At the same time the InProcNode is still running:
Though based on the code it seems like we do not want to kill InProcNode in VS:
msbuild/src/Build/BackEnd/BuildManager/BuildParameters.cs
Lines 596 to 604 in ab7c289
| /// <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:
msbuild/src/Build/BackEnd/BuildManager/BuildManager.cs
Lines 2558 to 2587 in ab7c289
| 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

