Deadlock at ExecuteSubmission vs LoggingService during shutdown #6712
Labels
bug
performance
Performance-Scenario-Build
This issue affects build performance.
triaged
Visual Studio
Issues relevant to Visual Studio scenarios
Issue Description
This deadlock has been detected while investigating
This bug has surfaced as hang at
BuildManager.EndBuild
.Steps to Reproduce
This race condition triggered deadlock is very hard to reproduce.
However there are many CABs which includes
devenv
process dump which helped during issue investigation.I have used this CAB during investigation.
Analysis
During execution BuildManager.ExecuteSubmission if build is canceled at particular time and following if branch is entered
msbuild/src/Build/BackEnd/BuildManager/BuildManager.cs
Lines 1132 to 1141 in 38eec6f
Line
msbuild/src/Build/BackEnd/BuildManager/BuildManager.cs
Line 1138 in 38eec6f
_syncLock
and wait for all messages of logging service to be processed. Processing messages of logging service is performed on thread pool and it could callback BuildManager, for example:msbuild/src/Build/BackEnd/BuildManager/BuildManager.cs
Lines 2815 to 2818 in 38eec6f
Locking
_syncLock
in callback fromLoggingService
concludes this deadlock.Prove:
Analysis
Code as is, is very fragile and hard to maintain. We shall strategically avoid, if possible, infinite lock-blocking callbacks from
LoggingService
intoBuildManager
Proposed solution:
OnProjectStarting/Finishing
seems to be dead. Nothing uses its results. I recommend to delete it and stop propagating project started and finished to BuildManager.OnThreadException
Versions & Configurations
This error might have been there for ages, at least since 2018 commit 764fe79.
The text was updated successfully, but these errors were encountered: