msbuild
msbuild copied to clipboard
[Bug]: ObjectDisposedException in BuildManager.BuildGraph
Issue Description
A customer is seeing an exception when building with /graph:
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Microsoft.Win32.SafeHandles.SafeWaitHandle'.
at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
at System.Threading.EventWaitHandle.Set()
at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass99_0.<BuildGraph>b__2(BuildSubmission finishedBuildSubmission)
at Microsoft.Build.Shared.ThreadPoolExtensions.<>c__DisplayClass0_0.<QueueThreadPoolWorkItemWithCulture>b__0(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Steps to Reproduce
Build a specific internal repo
Expected Behavior
The build doesn't crash
Actual Behavior
The build crashes
Analysis
No response