Skip to content

Enhance crash dump collection options in RemoteExecutor - #16716

Merged
hoyosjs merged 16 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/remote-exec-dumps
Jun 30, 2026
Merged

hoyosjs merged 16 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/remote-exec-dumps

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Apr 14, 2026

Copy link
Copy Markdown
Member

This pull request introduces improved and more flexible crash dump collection for remote test processes, with enhanced configuration options and updated diagnostics support. The changes modernize how dumps are collected, update dependencies, and add new options for controlling dump behavior.

  • Update package references for Microsoft.Diagnostics.Runtime and Microsoft.Diagnostics.NETCore.Client.
  • Introduce CrashDumpCollectionType enum to specify types of crash dumps.
  • Add options to enable/disable crash dump collection and configure related environment variables so tests that are expected to crash can disable the behaviors (at least the .NET env var based ones - no changes to LocalDumps and AEDebug).

- Update package references for Microsoft.Diagnostics.Runtime and Microsoft.Diagnostics.NETCore.Client.
- Introduce CrashDumpCollectionType enum to specify types of crash dumps.
- Add options to enable/disable crash dump collection and configure related environment variables.
@hoyosjs
hoyosjs requested review from agocke and leculver April 14, 2026 08:45

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for adding the ability to disable the collection @hoyosjs !

I am not approving the PR yet as I believe somebody more familiar with the APIs for ClrMD should verify the correct usage of APIs.

Comment thread Directory.Packages.props Resolved
leculver
leculver previously approved these changes Apr 23, 2026

@leculver leculver left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not approving the PR yet as I believe somebody more familiar with the APIs for ClrMD should verify the correct usage of APIs.

It's funny, I looked through this and didn't mash approve because I didn't understand the other half of the change. This LGTM from a ClrMD perspective.

There shouldn't be any regressions moving from 1.1 -> 4.0, in fact some things should start working that didn't before.

@hoyosjs
hoyosjs enabled auto-merge (squash) May 6, 2026 17:45
@hoyosjs

hoyosjs commented May 6, 2026

Copy link
Copy Markdown
Member Author

@adamsitnik - fixed all the feedback you had. Thanks

@leculver

leculver commented May 6, 2026

Copy link
Copy Markdown

Github is being weird and I can't comment on a specific line. But you should bump ClrMD to 4.0 rtm now.

@hoyosjs

hoyosjs commented May 10, 2026

Copy link
Copy Markdown
Member Author

@missymessa I had to update MS.Identity.Client and update a couple things in Microsoft.DotNet.ArcadeAzureIntegration/DefaultIdentityTokenCredential.cs - would you mind taking a look?

…crash-dumps

# Conflicts:
#	Directory.Packages.props
#	src/Microsoft.DotNet.ArcadeAzureIntegration/DefaultIdentityTokenCredential.cs
#	src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeHandle.cs
Copilot AI review requested due to automatic review settings June 27, 2026 00:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances diagnostics for remote test processes by adding configurable crash dump collection options to Microsoft.DotNet.RemoteExecutor, updating dump collection behavior on timeouts, and updating related dependencies.

Changes:

  • Add CrashDumpCollectionType + CrashDumpPath options to control DOTNET_Dbg* crash dump environment variables (including explicit disable behavior).
  • Add EnableTimeoutDumpCollection and refactor timeout diagnostics collection (dump + thread stacks) in RemoteInvokeHandle.
  • Update package references (add Microsoft.Diagnostics.NETCore.Client) and adjust compilation of MiniDump.cs per TFM.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Microsoft.DotNet.RemoteExecutor/tests/RemoteExecutorTests.cs Adds tests validating crash dump env var behavior and a dump-on-crash scenario.
src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeOptions.cs Introduces CrashDumpCollectionType, CrashDumpPath, and EnableTimeoutDumpCollection options.
src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeHandle.cs Refactors and expands timeout diagnostics collection; switches to DiagnosticsClient on .NET Core.
src/Microsoft.DotNet.RemoteExecutor/src/RemoteExecutor.cs Implements env var wiring/removal for crash dump collection options.
src/Microsoft.DotNet.RemoteExecutor/src/Microsoft.DotNet.RemoteExecutor.csproj Adds Microsoft.Diagnostics.NETCore.Client for .NET Core builds and removes MiniDump.cs there.
src/Microsoft.DotNet.ArcadeAzureIntegration/DefaultIdentityTokenCredential.cs Fixes managed identity selection to support system-assigned identity when no client id is provided.
Directory.Packages.props Adds centrally managed version for Microsoft.Diagnostics.NETCore.Client.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…gh test

- Use InvariantCulture when formatting DOTNET_DbgMiniDumpType env var.
- Collect heap (not full) dumps on timeout to avoid multi-GB Helix artifacts.
- Make the default-passthrough test assert the child observes the parent's env values instead of relying on the env being unset.

Co-authored-by: Copilot <[email protected]>

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoyosjs PTAL at my comments. It's almost ready, needs only some minor polishing related mostly to pre-existing logic that your PR itself has not introduced.

Copilot AI review requested due to automatic review settings June 29, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings June 29, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment on lines +171 to +180
using RemoteInvokeHandle h = RemoteExecutor.Invoke(expectedType =>
{
Assert.Equal("1", Environment.GetEnvironmentVariable("DOTNET_DbgEnableMiniDump"));
Assert.Equal(expectedType, Environment.GetEnvironmentVariable("DOTNET_DbgMiniDumpType"));
return RemoteExecutor.SuccessExitCode;
}, expectedTypeValue, new RemoteInvokeOptions
{
RollForward = "Major",
CrashDumpCollectionType = dumpType
});
Comment on lines +196 to +201
using RemoteInvokeHandle h = RemoteExecutor.Invoke(() =>
{
Assert.Null(Environment.GetEnvironmentVariable("DOTNET_DbgEnableMiniDump"));
Assert.Null(Environment.GetEnvironmentVariable("DOTNET_DbgMiniDumpType"));
Assert.Null(Environment.GetEnvironmentVariable("DOTNET_DbgMiniDumpName"));
}, options);
Comment on lines +217 to +223
using RemoteInvokeHandle h = RemoteExecutor.Invoke((enable, type, name) =>
{
Assert.Equal(enable, Environment.GetEnvironmentVariable("DOTNET_DbgEnableMiniDump"));
Assert.Equal(type, Environment.GetEnvironmentVariable("DOTNET_DbgMiniDumpType"));
Assert.Equal(name, Environment.GetEnvironmentVariable("DOTNET_DbgMiniDumpName"));
}, expectedEnable, expectedType, expectedName, options);
}
Comment on lines +248 to +253
string[] dumpFiles = Array.Empty<string>();
bool dumpCreated = SpinWait.SpinUntil(() =>
{
dumpFiles = Directory.GetFiles(dumpDir, "*.dmp");
return dumpFiles.Length > 0;
}, TimeSpan.FromSeconds(10));
{
string dumpPath = Path.Combine(uploadPath, $"{Process.Id}.{Path.GetRandomFileName()}.dmp");
#if NETCOREAPP
// These define guards assume that harness running on .NET Framework implies test process runs on .NET Framework.
- Use Invoke(...).Dispose() instead of unused 'using' locals in three
  crash-dump env-var tests for consistency with the rest of the file
- Inline dumpFiles into SpinWait.SpinUntil in CrashDumpCollection_CreatesDumpOnCrash
- Reword inaccurate #if NETCOREAPP comment in RemoteInvokeHandle.cs

Co-authored-by: Copilot <[email protected]>

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, big thanks for the improvements @hoyosjs ! I can't wait to collect dumps on macOS!

@hoyosjs
hoyosjs merged commit f87bce1 into dotnet:main Jun 30, 2026
10 checks passed
@hoyosjs
hoyosjs deleted the juhoyosa/remote-exec-dumps branch June 30, 2026 17:50
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants