dotnet / dotnet/BenchmarkDotNet

Race condition in Broker

Open
#2,317 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
11.5k
Forks
1.1k
Avg merge
6d 11h
Merged PRs (30d)
12

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.