mono / monodevelop

MonoDevelop is a cross platform .NET IDE
http://www.monodevelop.com
2.84k stars 1.02k forks source link

[release-8.4] [Core] Fix remote project builder deadlock #9428

Closed monojenkins closed 4 years ago

monojenkins commented 4 years ago

UI hang can occur when the UI thread and a background thread are updating the remote project builders at the same time due to two locks being accessed in a different order.

Background thread:

RemoteBuildEngine.GetRemoteProjectBuilder - locks remoteProjectBuilders RemoteProjectBuilder.AddReference - locks usageLock

UI thread:

RemoteProjectBuilder.Shutdown - locks usageLock RemoteProjectBuilder.Dispose RemoteBuildEngine.UnloadProject RemoteBuildEngine.RemoveBuilder - locks remoteProjectBuilders

To avoid this the RemoteBuildEngine.UnloadProject is not done synchronously in the RemoteProjectBuilder's Dispose method.

Fixes VSTS #1030374 - [FATAL] SigTerm signal in MonoDevelop.Core.dll! MonoDevelop.Projects.MSBuild.RemoteBuildEngine::RemoveBuilder+9

Backport of #9427.

/cc @slluis @mrward