Skip to content

[Diagnostics] Enable .NET Runtime crash reporting before signal chaining#11291

Merged
jonathanpeppers merged 3 commits into
mainfrom
copilot/enable-crash-reporting-order
May 13, 2026
Merged

[Diagnostics] Enable .NET Runtime crash reporting before signal chaining#11291
jonathanpeppers merged 3 commits into
mainfrom
copilot/enable-crash-reporting-order

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

Android registers signal handlers before .NET's runtime, causing Android to kill the process before .NET crash reporting can run. The System.Runtime.CrashReportBeforeSignalChaining property (dotnet/runtime#123735) allows flipping this order.

Changes

  • Microsoft.Android.Sdk.RuntimeConfig.targets: Add internal _AndroidEnableDiagnosticCrashReporting MSBuild property (default true) and wire it to System.Runtime.CrashReportBeforeSignalChaining via RuntimeHostConfigurationOption

With this enabled, managed callstacks are logged and a crash report JSON is written to disk on crash (dotnet/runtime#123824, dotnet/runtime#126916).

The property is internal and undocumented, serving only as an escape hatch if the behavior needs to be disabled:

<PropertyGroup>
  <_AndroidEnableDiagnosticCrashReporting>false</_AndroidEnableDiagnosticCrashReporting>
</PropertyGroup>

…ash reporting before signal chaining

Agent-Logs-Url: https://github.com/dotnet/android/sessions/55e4fb9d-2935-4e5a-961c-386c256574cc

Co-authored-by: mdh1418 <16830051+mdh1418@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable .NET Runtime crash reporting before signal chaining [Diagnostics] Enable .NET Runtime crash reporting before signal chaining May 5, 2026
Copilot AI requested a review from mdh1418 May 5, 2026 17:18
Copilot finished work on behalf of mdh1418 May 5, 2026 17:18
`False` if using `$(AndroidDexTool)=dx` and `True` if
using [`$(AndroidDexTool)`](#androiddextool)=`d8`.

## AndroidEnableDiagnosticCrashReporting
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.

Same question I had here, does this need to be public?

If it's something a customer won't understand/use, it could be $(_AndroidEnableDiagnosticCrashReporting) and undocumented. It would only exist as an optional escape hatch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to _AndroidEnableDiagnosticCrashReporting and removed the docs in fc677d6. It's now an undocumented internal escape hatch only.

@simonrozsival
Copy link
Copy Markdown
Member

@copilot switch the property to _AndroidEnableDiagnosticCrashReporting and drop the documentation for now.

…entation

Agent-Logs-Url: https://github.com/dotnet/android/sessions/aabc6bed-6957-4252-826a-3d338ef4592f

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
@simonrozsival simonrozsival marked this pull request as ready for review May 13, 2026 11:50
Copilot AI review requested due to automatic review settings May 13, 2026 11:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the Android SDK MSBuild runtimeconfig wiring to enable .NET runtime crash reporting before Android’s signal chaining runs, so managed crash reporting can execute instead of the process being terminated first.

Changes:

  • Introduces an internal _AndroidEnableDiagnosticCrashReporting MSBuild property (defaulting to true).
  • Emits System.Runtime.CrashReportBeforeSignalChaining as a RuntimeHostConfigurationOption, driven by that property.

@jonathanpeppers jonathanpeppers merged commit 3e91f96 into main May 13, 2026
7 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/enable-crash-reporting-order branch May 13, 2026 16:02
jonathanpeppers added a commit that referenced this pull request May 15, 2026
### Add NativeCrashProducesManagedStackTrace device test

Adds an MSBuildDeviceIntegration test that verifies the
System.Runtime.CrashReportBeforeSignalChaining config option works
end-to-end on CoreCLR. The test builds a Release app that triggers
a native SIGSEGV via P/Invoke to libc memset(NULL), then checks
logcat for the managed stack trace logged by the DOTNET tag before
Android's signal handler takes over.

See: #11291
See: dotnet/runtime#123735

### Assert SIGSEGV signal and add runtime PR reference

- Assert that logcat contains both SIGSEGV signal and ForceNativeSegfault
  managed frame from the DOTNET tag
- Add reference to dotnet/runtime#123824 which implements the managed
  callstack logging

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[Diagnostics] Enable .NET Runtime crash reporting before signal chaining

5 participants