Skip to content

Race condition in Broker #2317

Open
Open
@AndreyAkinshin

Description

@AndreyAkinshin

Occasionally, our integration tests fail with the following exception:

 The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.ObjectDisposedException: Safe handle has been closed.
Object name: 'SafeHandle'.
   at Interop.Kernel32.SetEvent(SafeWaitHandle handle)
   at System.Threading.EventWaitHandle.Set()
   at BenchmarkDotNet.Loggers.Broker.OnProcessExited(Object sender, EventArgs e) in /home/runner/work/BenchmarkDotNet/BenchmarkDotNet/src/BenchmarkDotNet/Loggers/Broker.cs:line 73
   at System.Diagnostics.Process.RaiseOnExited()
   at System.Diagnostics.Process.CompletionCallback(Object waitHandleContext, Boolean wasSignaled)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.PortableThreadPool.CompleteWait(RegisteredWaitHandle handle, Boolean timedOut)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Results File: /home/runner/work/BenchmarkDotNet/BenchmarkDotNet/TestResults/IntegrationTests-net7.0.trx

Test Run Aborted with error System.Exception: One or more errors occurred.
Passed!  - Failed:     0, Passed:    94, Skipped:     0, Total:    94, Duration: 10 m 41 s - BenchmarkDotNet.IntegrationTests.dll (net7.0)
 ---> System.Exception: Unable to read beyond the end of the stream.
   at System.IO.BinaryReader.Read7BitEncodedInt()
   at System.IO.BinaryReader.ReadString()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action`1 errorHandler, CancellationToken cancellationToken)

Build example: https://github.com/dotnet/BenchmarkDotNet/actions/runs/5131337302/jobs/9231285726

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions