Skip to content

Enhance crash dump collection options in RemoteExecutor#16716

Open
hoyosjs wants to merge 9 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/remote-exec-dumps
Open

Enhance crash dump collection options in RemoteExecutor#16716
hoyosjs wants to merge 9 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 src/Microsoft.DotNet.RemoteExecutor/src/MiniDump.cs Outdated
Comment thread Directory.Packages.props Outdated
Comment thread src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeOptions.cs Outdated
Comment thread src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeOptions.cs
Comment thread src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeHandle.cs
Comment thread src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeOptions.cs Outdated
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.

else if (options.CrashDumpCollectionType.HasValue)
{
psi.Environment["DOTNET_DbgEnableMiniDump"] = "1";
psi.Environment["DOTNET_DbgMiniDumpType"] = ((int)options.CrashDumpCollectionType.Value).ToString();
Comment on lines +216 to +220
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.
var client = new DiagnosticsClient(Process.Id);
client.WriteDump(DumpType.Full, dumpPath, logDumpGeneration: false);
Comment on lines +203 to +215
[Fact]
public void CrashDumpCollection_DefaultLeavesEnvVarsUntouched()
{
// When neither option is set, env vars should pass through from the parent unchanged
using RemoteInvokeHandle h = RemoteExecutor.Invoke(() =>
{
// Without explicit config, the child inherits whatever the parent has.
// The parent test process shouldn't have DOTNET_DbgEnableMiniDump set,
// so the child shouldn't either.
string parentValue = Environment.GetEnvironmentVariable("DOTNET_DbgEnableMiniDump");
Assert.Null(parentValue);
}, new RemoteInvokeOptions { RollForward = "Major" });
}
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