Skip to content

Make NativeAOT crash info serialization configurable - #137169

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:crashinfo
Nov 12, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:crashinfo

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

2.5% size saving on WASM, probably similar with DebuggerSupport=false elsewhere (I'll let rt-sz measure that one).

Also considered whether to seed this from StackTraceSupport=false but decided not to for now.

CrashInfoSupport property by itself will probably stay as an undocumented escape hatch.

Add the System.Diagnostics.CrashInfo.IsSupported feature switch and gate crash-info serialization. Default CrashInfoSupport to false when unset and either debugger support is disabled or WASM native stripping is enabled, while preserving explicit opt-in.

Evaluate the WASM strip default before feature-switch configuration. Keep IsSupported constant true so disabled builds trim serialization without adding overhead to enabled builds.

Reduces the invariant-globalization NativeAOT WASI Hello World from 762,001 to 742,927 bytes, saving 19,074 bytes (2.50%). Explicit opt-in retains the original 762,001-byte size.

Validated 81 MSBuild policy combinations, enabled/disabled fatal paths on WASI Release and Checked, exception and preinitialization smoke tests, and Windows x64 Debug CoreLib compilation.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 9bc3dfee-1040-4648-bdad-86922a749613
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

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.

🟢 Approval recommended

No active review issues are reported for the change making NativeAOT crash-info serialization configurable.

No open issues 🎉

What changed in this PR

Makes NativeAOT crash-info serialization configurable so size-focused builds can omit it.

Changes:

  • Adds a feature switch and skips crash-info serialization when disabled.
  • Defaults CrashInfoSupport to false when debugger support is disabled or WebAssembly native stripping is enabled, while preserving explicit overrides.
  • Moves the WebAssembly stripping default into the common NativeAOT targets so it is available when configuring crash-info support.
File Description
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​System/​RuntimeExceptionHelpers.cs Skips serialization when crash-info support is disabled.
src/​coreclr/​nativeaot/​System.Private.CoreLib/​src/​System/​CrashInfo.cs Defines the crash-info feature switch.
src/​coreclr/​nativeaot/​BuildIntegration/​Microsoft.NETCore.Native.Wasm.targets Removes the relocated WebAssembly stripping default.
src/​coreclr/​nativeaot/​BuildIntegration/​Microsoft.NETCore.Native.targets Sets stripping and crash-info defaults and emits the trimming configuration.

Review effort: Balanced

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Besides the 2.5% win on WASM, this also has small wins outside of it but requires opting in with DebuggerSupport=false:

Project Size before Size after Difference
TodosApi-linux 24768200 24760008 -8192
TodosApi-windows 25806336 25799168 -7168
avalonia.app-linux 18730952 18722760 -8192
avalonia.app-windows 19066368 19058688 -7680
hello-linux 1126792 1114472 -12320
hello-minimal-linux 991504 979168 -12336
hello-minimal-windows 772096 758784 -13312
hello-windows 929280 912384 -16896
kestrel-minimal-linux 5417208 5409016 -8192
kestrel-minimal-windows 4934144 4926464 -7680
reflection-linux 1795216 1791120 -4096
reflection-windows 1665536 1652224 -13312
webapiaot-linux 9911648 9907552 -4096
webapiaot-windows 10399744 10392576 -7168
winrt-component-minimal-windows 722432 701440 -20992

@jkotas

jkotas commented Nov 11, 2026

Copy link
Copy Markdown
Member

@lateralusX @dotnet/dotnet-diag This is another configuration option for configuring crash diagnostics. We have been growing the number of crash diagnostic options rapidly. I am wondering whether there is a work to do to ensure that the options form a coherent story.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@lateralusX @dotnet/dotnet-diag This is another configuration option for configuring crash diagnostics. We have been growing the number of crash diagnostic options rapidly. I am wondering whether there is a work to do to ensure that the options form a coherent story.

The idea is that CrashInfoSupport would be undocumented. (I guess I should name this IlcCrashInfoSupport). The only documented entrypoint is the existing DebuggerSupport. I left some way to control it individually because we generally do have these undocumented escape hatches just in case someone e.g. wants to dig out the CrashInfo data by looking for things that look like the utf-8 JSON payload in the dump.

@MichalStrehovsky
MichalStrehovsky merged commit 5525282 into dotnet:main Nov 12, 2026
111 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the crashinfo branch November 12, 2026 07:50
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants