Uh oh!
There was an error while loading. Please reload this page.
Implement UnhandledException hook for finalizer scenario in Mono. - #118563
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements the UnhandledException hook for finalizer scenarios in Mono runtime, building on previous work in shared corelib code. The implementation ensures that unhandled exceptions in finalizers are properly handled through the global exception handler mechanism.
Key changes:
- Introduces a new
GuardedFinalizemethod that wraps finalizer calls with exception handling - Updates Mono's finalizer execution path to use the guarded version instead of direct finalizer calls
- Enables previously excluded UnhandledException tests for Mono (with some exceptions)
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/tests/issues.targets | Enables UnhandledException tests for Mono, excluding only specific problematic test cases |
| src/mono/mono/mini/aot-compiler.c | Updates AOT compilation to use GuardedFinalize instead of Finalize for runtime-invoke |
| src/mono/mono/metadata/gc.c | Modifies finalizer execution to call GuardedFinalize and updates method resolution |
| src/mono/System.Private.CoreLib/src/System/Object.Mono.cs | Implements GuardedFinalize method with exception handling using UnsafeAccessor |
| src/mono/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml | Preserves GuardedFinalize method from IL linking removal |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
VSadov
commented
Aug 13, 2025
I think this is ready for a review. There are some failures on ios/tvos, but I cannot tell if these are caused by the change. |
VSadov
commented
Aug 14, 2025
This keeps failing on ios/tvos. I am out of ideas why. @lambdageek - could you take a look? |
Uh oh!
There was an error while loading. Please reload this page.
@VSadov I can't really see anything in the CI logs, but probably something needs to tell Mono's AOT compiler to compile |
kotlarmilos
commented
Aug 15, 2025
Let me run it locally to try to get better diagnostics/ stack trace. |
kotlarmilos
commented
Aug 15, 2025
I am getting the following error on iOS arm64 device: |
I think I am precompiling the wrapper. We had the same pattern before, just the wrapper was for The wrapper for |
Making Virtual |
Uh oh!
There was an error while loading. Please reload this page.
LLVMFULLAOT fails in The rest is passing now, including the newly enabled tests for |
VSadov
commented
Aug 19, 2025
/ba-g LLVMFULLAOT failure in Regression_2 is unrelated. Happens without this change as well (see: NOOP change in #118642) |
VSadov
commented
Aug 19, 2025
Thanks for reviewing! |
Uh oh!
There was an error while loading. Please reload this page.
VSadov
commented
Aug 19, 2025
/backport to release/10.0-rc1 |
Started backporting to release/10.0-rc1: https://github.com/dotnet/runtime/actions/runs/17064173533 |
A follow-up for #109806
Most of the implementation is in the shared corelib code and works for Mono, but finalization scenario needs special handling as that part is not shared.