Skip to content

Narrow Mono AOT typeload error cleanup#129748

Merged
vitek-karas merged 2 commits into
dotnet:mainfrom
vitek-karas:copilot/issue-129613-main
Jun 24, 2026
Merged

Narrow Mono AOT typeload error cleanup#129748
vitek-karas merged 2 commits into
dotnet:mainfrom
vitek-karas:copilot/issue-129613-main

Conversation

@vitek-karas

@vitek-karas vitek-karas commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

  • consume the expected recoverable MissingField / BadImage metadata errors after lowering Mono AOT field-resolution failures into runtime throw IR
  • add a direct Mono mini regression in src/mono/mono/mini/iltests.il that covers a generic missing-field access followed by a later accepted inline in the same compiled method

Testing

  • ./build.sh mono -os iossimulator -arch arm64 -c Release -rf mono
  • validated manually against the 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()
  • local Mono-style regression validation for src/mono/mono/mini/iltests.il:
    • mono iltests.exe --run-only missing_field_then_inline
    • mono --aot=full,static iltests.exe

This 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.

vitek-karas and others added 2 commits June 23, 2026 15:24
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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, clear cfg->error for MONO_ERROR_MISSING_FIELD in the same “recoverable metadata error” bucket as MONO_ERROR_BAD_IMAGE on the AOT-only field-resolution recovery path.
  • Add a new iltests.il regression (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.

@vitek-karas

Copy link
Copy Markdown
Member Author

To follow the rules - fix this in main first.

@vitek-karas vitek-karas requested a review from BrzVlad June 23, 2026 14:54
@vitek-karas vitek-karas added this to the 11.0.0 milestone Jun 23, 2026
@vitek-karas vitek-karas marked this pull request as ready for review June 23, 2026 14:54
@vitek-karas vitek-karas requested a review from steveisok as a code owner June 23, 2026 14:54
@vitek-karas

Copy link
Copy Markdown
Member Author

/ba-g The one unrecognized failure is a bug being fixed by #129713

@vitek-karas vitek-karas merged commit 91045b2 into dotnet:main Jun 24, 2026
83 of 87 checks passed
@vitek-karas vitek-karas deleted the copilot/issue-129613-main branch June 24, 2026 15:37
@vitek-karas

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

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>
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview7 Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 134

4 participants