Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/SOS/SOS.UnitTests/SOSRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,10 @@ public static async Task<string> CreateDump(TestInformation information)
if (pipeServer != null)
{
dotnetDumpOutputHelper.WriteLine("Waiting for connection on pipe {0}", pipeName);
CancellationTokenSource source = new(TimeSpan.FromMinutes(5));
using CancellationTokenSource source = new(TimeSpan.FromMinutes(5));

// Wait for debuggee to connect/write to pipe or if the process exits on some other failure/abnormally
// TODO: This is a resiliency issue - we'll try to collect the dump even if the debuggee fails to connect.
await Task.WhenAny(pipeServer.WaitForConnectionAsync(source.Token), processRunner.WaitForExit());
}

Expand Down
12 changes: 10 additions & 2 deletions src/tests/CommonTestRunner/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,16 @@ public async Task WaitForTracee()
WriteLine("WaitForTracee");
try
{
CancellationTokenSource source = new(TimeSpan.FromMinutes(2));
await _pipeServer.WaitForConnectionAsync(source.Token).ConfigureAwait(false);
using CancellationTokenSource source = new(TimeSpan.FromMinutes(2));
Task processDeath = _runner.WaitForExit();
Task traceeReady = _pipeServer.WaitForConnectionAsync(source.Token);
Task doneTask = await Task.WhenAny(processDeath, traceeReady).WaitAsync(source.Token).ConfigureAwait(false);

source.Cancel();
if (doneTask == processDeath)
{
Trace.TraceWarning($"WaitForTracee: process {Pid} exited without sending the event");
}
WriteLine("WaitForTracee: DONE");
}
catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException)
Expand Down
16 changes: 14 additions & 2 deletions src/tests/DbgShim.UnitTests/DebuggeeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,21 @@ public async Task<bool> WaitForDebuggee()
}
try
{
CancellationTokenSource source = new(TimeSpan.FromMinutes(5));
using CancellationTokenSource source = new(TimeSpan.FromMinutes(5));
Trace.TraceInformation($"DebuggeeInfo.WaitForDebuggee: waiting {ProcessId}");
await _pipeServer.WaitForConnectionAsync(source.Token);

Task processDeath = _process.WaitForExitAsync(source.Token);
Task debuggeeReady = _pipeServer.WaitForConnectionAsync(source.Token);
Task doneTask = await Task.WhenAny(processDeath, debuggeeReady).WaitAsync(source.Token);

source.Cancel();

if (doneTask == processDeath)
{
Trace.TraceWarning($"DebuggeeInfo.WaitForDebuggee: process {ProcessId} exited");
return false;
}

Trace.TraceInformation($"DebuggeeInfo.WaitForDebuggee: after wait {ProcessId}");
}
catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException)
Expand Down