[Diagnostics] Enable .NET Runtime crash reporting before signal chaining#11291
Conversation
…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>
| `False` if using `$(AndroidDexTool)=dx` and `True` if | ||
| using [`$(AndroidDexTool)`](#androiddextool)=`d8`. | ||
|
|
||
| ## AndroidEnableDiagnosticCrashReporting |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Renamed to _AndroidEnableDiagnosticCrashReporting and removed the docs in fc677d6. It's now an undocumented internal escape hatch only.
|
@copilot switch the property to |
…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>
There was a problem hiding this comment.
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
_AndroidEnableDiagnosticCrashReportingMSBuild property (defaulting totrue). - Emits
System.Runtime.CrashReportBeforeSignalChainingas aRuntimeHostConfigurationOption, driven by that property.
### 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>
Android registers signal handlers before .NET's runtime, causing Android to kill the process before .NET crash reporting can run. The
System.Runtime.CrashReportBeforeSignalChainingproperty (dotnet/runtime#123735) allows flipping this order.Changes
Microsoft.Android.Sdk.RuntimeConfig.targets: Add internal_AndroidEnableDiagnosticCrashReportingMSBuild property (defaulttrue) and wire it toSystem.Runtime.CrashReportBeforeSignalChainingviaRuntimeHostConfigurationOptionWith 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: