-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Serialize unhandled exception for crash dump analysis when ExceptionHandler.RaiseUnhandledExceptionEvent is called #117832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize unhandled exception for crash dump analysis when ExceptionHandler.RaiseUnhandledExceptionEvent is called #117832
Conversation
…andler.RaiseUnhandledExceptionEvent is called
There was a problem hiding this 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 extends the NativeAOT crash dump analysis feature to work with host-notified unhandled exceptions by adding exception serialization when ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent
is called. Previously, the SOS !crashinfo
command only worked for NativeAOT's internal crash dump code path.
- Adds crash info serialization to the
OnUnhandledException
method inAppContext.cs
- Refactors crash info handling in
RuntimeExceptionHelpers.cs
to enable reuse across different crash scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/libraries/System.Private.CoreLib/src/System/AppContext.cs | Adds call to serialize crash info for unhandled exceptions in NativeAOT builds |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs | Refactors crash info creation into reusable method and adds thread-safe caching |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Jan Kotas <[email protected]>
…erialized (prevents early process exit)
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
…eExceptionHelpers.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs
Outdated
Show resolved
Hide resolved
…eExceptionHelpers.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
/ba-g failures are unrelated |
…andler.RaiseUnhandledExceptionEvent is called (dotnet#117832) * Serialize unhandled exception for crash dump analysis when ExceptionHandler.RaiseUnhandledExceptionEvent is called * Use cheaper locking mechanism for SerializeCrashInfo * Remove superfluous assignment * Apply suggestions from code review Co-authored-by: Jan Kotas <[email protected]> * Block secondary calls to SerializeCrashInfo until the data has been serialized (prevents early process exit) * Update src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs * Update src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs --------- Co-authored-by: Jan Kotas <[email protected]>
…andler.RaiseUnhandledExceptionEvent is called (#117832) (#117913) * Serialize unhandled exception for crash dump analysis when ExceptionHandler.RaiseUnhandledExceptionEvent is called * Use cheaper locking mechanism for SerializeCrashInfo * Remove superfluous assignment * Apply suggestions from code review * Block secondary calls to SerializeCrashInfo until the data has been serialized (prevents early process exit) * Update src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs * Update src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs --------- Co-authored-by: Jan Kotas <[email protected]> Co-authored-by: Jeff Schwartz <[email protected]>
SOS supports reading NAOT crash information using a JSON encoding mechanism. The mechanism relies on passing the serialized exception address via a [FailFast exception parameter](https://github.com/dotnet/runtime/blob/67837792faa88beb3f44105dfa7a3a430961ff12/src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeExceptionHelpers.cs#L322-L332) along with a special code. SOS can read this data via `!crashinfo` as well as `!clrma`. As of dotnet/runtime#117832, NAOT can serialize exception data when `ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent` is called. This PR adds the corresponding SOS functionality to locate the [g_CrashInfoBuffer](https://github.com/dotnet/runtime/blob/67837792faa88beb3f44105dfa7a3a430961ff12/src/coreclr/nativeaot/Runtime/DebugHeader.cpp#L261) global as an alternate mechanism in the event the exception does not contain the address of the buffer. Since this requires reading module exports, this change introduces a configurable module enumeration mechanism via the `!crashinfo` command. --------- Co-authored-by: Michal Strehovský <[email protected]>
SOS supports a feature that is able to read a serialized exception embedded in a NativeAOT mini-dump, known as
!crashinfo
. This feature was added in the .NET 8 timeframe, but only worked when executing NativeAOT's internal crash dump code path. #114392 added the ability for hosts to notify the runtime of an impending unhandled exception through theExceptionHandling.RaiseAppDomainUnhandledExceptionEvent
API.