You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Native AOT does not use C++ or SEH exceptions, meaning that debuggers do not recognize the exception throw/catch sequence and cannot break on first-chance exceptions. On Windows, we can use OS functionality to throw and catch an SEH exception when a Native AOT exception is thrown and a debugger is attached, effectively acting as a notification to debuggers that an exception is in flight. The exception code used here is the same one as CoreCLR, so the WinDbg command sxe clr would also be sufficient to catch Native AOT exceptions.
Native AOT does not use C++ or SEH exceptions, meaning that debuggers do
not recognize the exception throw/catch sequence and cannot break on
first-chance exceptions. On Windows, we can use OS functionality to
throw and catch an SEH exception when a Native AOT exception is thrown
and a debugger is attached, effectively acting as a notification to
debuggers that an exception is in flight. The exception code used here
is the same one as CoreCLR, so the WinDbg command `sxe clr` would also
be sufficient to catch Native AOT exceptions.
Fixesdotnet#115514
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a notification mechanism for attached debuggers when a Native AOT exception is thrown by throwing and catching an SEH exception on Windows.
Replace PAL_TRY/PAL_EXCEPT with __try/__except for Windows-specific exception notifications.
Introduce RhpFirstChanceException in EHHelpers.cpp and expose it in InternalCalls.cs and ExceptionHandling.cs.
Add exception code definitions in corexcep.h to ensure consistency with CoreCLR.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File
Description
src/coreclr/vm/exceptionhandling.cpp
Updated exception notification logic for Windows.
src/coreclr/nativeaot/Runtime/corexcep.h
Added exception code definitions used by the CLR.
src/coreclr/nativeaot/Runtime/EHHelpers.cpp
Introduced RhpFirstChanceException function with Windows-specific logic.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native AOT does not use C++ or SEH exceptions, meaning that debuggers do not recognize the exception throw/catch sequence and cannot break on first-chance exceptions. On Windows, we can use OS functionality to throw and catch an SEH exception when a Native AOT exception is thrown and a debugger is attached, effectively acting as a notification to debuggers that an exception is in flight. The exception code used here is the same one as CoreCLR, so the WinDbg command
sxe clr
would also be sufficient to catch Native AOT exceptions.Fixes #115514