Narrow Mono AOT typeload error cleanup#129748
Merged
Merged
Conversation
Only clear the expected recoverable field-resolution metadata errors after lowering the failure into runtime throw IR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Mono’s IL-to-IR pipeline for AOT compilation to ensure recoverable field-resolution failures don’t leave a live cfg->error behind after being lowered into a runtime throw, and adds an IL regression to cover the scenario.
Changes:
- In
mono_method_to_ir, clearcfg->errorforMONO_ERROR_MISSING_FIELDin the same “recoverable metadata error” bucket asMONO_ERROR_BAD_IMAGEon the AOT-only field-resolution recovery path. - Add a new
iltests.ilregression (test_0_missing_field_then_inline) that triggers a generic missing-field access followed by a later inlining opportunity in the same compiled method.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/mono/mono/mini/method-to-ir.c | Extends the existing AOT-only error cleanup to also consume MONO_ERROR_MISSING_FIELD, preventing later inline acceptance from hitting mono_error_assert_ok (cfg->error). |
| src/mono/mono/mini/iltests.il | Adds a targeted IL regression that exercises a missing-field memberref in a generic method followed by an inline candidate call. |
Member
Author
|
To follow the rules - fix this in main first. |
BrzVlad
approved these changes
Jun 23, 2026
lewing
approved these changes
Jun 23, 2026
Member
Author
|
/ba-g The one unrecognized failure is a bug being fixed by #129713 |
Member
Author
|
/backport to release/10.0 |
Contributor
|
Started backporting to |
4 tasks
steveisok
pushed a commit
that referenced
this pull request
Jun 24, 2026
Backport of #129748 to release/10.0 /cc @vitek-karas ## Customer Impact - [x] Customer reported - [ ] Found internally Fixes #129613 Without this fix, some customer apps fail to AOT compile on .NET 10 with an assertion in `inline_method()` followed by `Failed to AOT compile ... exited with code 134`. In the reported case this blocks publishing an iOS app with Mono AOT, while the same scenario worked on .NET 8. ## Regression - [x] Yes - [ ] No This is a regression between .NET 8 and .NET 9 introduced by #91261. ## Testing - `./build.sh mono -os iossimulator -arch arm64 -c Release -rf mono` - validated manually against the customer issue sample / reduced repro by replaying the exact failing AOT compiler command and confirming the fixed compiler succeeds where the regressed compiler asserts in `inline_method()` - added a direct Mono mini regression in `src/mono/mono/mini/iltests.il` - local regression validation: - `mono iltests.exe --run-only missing_field_then_inline` - `mono --aot=full,static iltests.exe` ## Risk Low. This is a targeted fix in Mono AOT compiler error handling plus a focused regression test. The change modifies a path which always fails to correctly handle the missing field reference and allow the application to compile (the error is then reported at runtime when the affected code path executes). **IMPORTANT**: If this backport is for a servicing release, please verify that: - For .NET 8 and .NET 9: The PR target branch is `release/X.0-staging`, not `release/X.0`. - For .NET 10+: The PR target branch is `release/X.0` (no `-staging` suffix). ## Package authoring no longer needed in .NET 9 **IMPORTANT**: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version. Keep in mind that we still need package authoring in .NET 8 and older versions. --------- Co-authored-by: vitek-karas <10670590+vitek-karas@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
MissingField/BadImagemetadata errors after lowering Mono AOT field-resolution failures into runtime throw IRsrc/mono/mono/mini/iltests.ilthat covers a generic missing-field access followed by a later accepted inline in the same compiled methodTesting
./build.sh mono -os iossimulator -arch arm64 -c Release -rf monoinline_method()src/mono/mono/mini/iltests.il:mono iltests.exe --run-only missing_field_then_inlinemono --aot=full,static iltests.exeThis doesn't add a CI runnable test as that would require lot of infra which feels a bit too much for servicing change. (I did try, and hitting this is not simple especially with end-to-end test)
Fixes #129613.