[CoreCLR] Propagate unhandled exceptions #10658
Open
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.
When using the CoreCLR runtime, the AppDomain.UnhandledException event handlers were not raised. This has many implications, one of them being that crash reporting tools don't work as expected.
This PR adds the missing functionality of forwarding the exceptions from native code to managed code. Some notable aspects of this PR:
ExceptionHandling.RaiseAppDomainUnhandledExceptionEventinstead of Mono's nativemono_unhandled_exceptionto raise the events. There is one observable change in behavior and that's that CoreCLR does not pass thesender(Mono passes the app domain). The existing unit test had to reflect this change.JNIEnvInit.Initializemethod returns the UCO fnptr through theargsstruct. I believe this is a clean way of doing it and hopefully it doesn't add too much confusion. This is a more efficient way of obtaining the function pointer than callingcoreclr_create_delegate. We have to use this to get the delegate for theInitializemethod itself, but it might be a good idea to return the funptr forRegisterNativesthis way as well (and avoid passing it completely at some later point when we have working Marshal Methods on CoreCLR, allowing for (unmeasurably?) faster startup and improved trimming)Closes #10657
Closes #10654