Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][aot] Fix compilation crashes when type load exception is generated in code #110078

Merged
merged 2 commits into from
Nov 28, 2024

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Nov 22, 2024

Following #91261, exception throwing during aot compilation for type load exceptions was replaced with throwing of exception at runtime, as part of the method code. This code insertion could hit some issues in various scenarios. Fixes #110003 and #109966

@vitek-karas
Copy link
Member

Sorry - no idea about the code change... but a question about the regression:
I'm curious how it is that it was in 9.0 for a year and we didn't detect it? Are we missing some tests, should we add them as part of this change?

@@ -6262,6 +6262,9 @@ method_make_alwaysthrow_typeloadfailure (MonoCompile* cfg, MonoClass* klass)
mono_link_bblock (cfg, bb, cfg->bb_exit);

cfg->disable_inline = TRUE;

for (int i = 0; i < cfg->header->num_clauses; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0; i < cfg->header->num_clauses; i++)
for (guint i = 0; i < cfg->header->num_clauses; i++)

Method compilation was continuing and we ended up failing with invalid IL.
…ption throw

In the final stages of method compilation, when trying to compute clause ranges, we were asserting because the clause bblocks haven't been reached for compilation.
@BrzVlad
Copy link
Member Author

BrzVlad commented Nov 29, 2024

/backport to release/9.0

Copy link
Contributor

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/12081654970

Copy link
Contributor

@BrzVlad backporting to release/9.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: [mono][aot] Fix stack state when emitting type load throw
Using index info to reconstruct a base tree...
M	src/mono/mono/mini/method-to-ir.c
Falling back to patching base and 3-way merge...
Auto-merging src/mono/mono/mini/method-to-ir.c
CONFLICT (content): Merge conflict in src/mono/mono/mini/method-to-ir.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 [mono][aot] Fix stack state when emitting type load throw
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

@BrzVlad an error occurred while backporting to release/9.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@BrzVlad
Copy link
Member Author

BrzVlad commented Nov 29, 2024

/backport to release/9.0-staging

Copy link
Contributor

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12084366956

Copy link
Contributor

@BrzVlad backporting to release/9.0-staging failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: [mono][aot] Fix stack state when emitting type load throw
Using index info to reconstruct a base tree...
M	src/mono/mono/mini/method-to-ir.c
Falling back to patching base and 3-way merge...
Auto-merging src/mono/mono/mini/method-to-ir.c
CONFLICT (content): Merge conflict in src/mono/mono/mini/method-to-ir.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 [mono][aot] Fix stack state when emitting type load throw
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

@BrzVlad an error occurred while backporting to release/9.0-staging, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

mikelle-rogers pushed a commit to mikelle-rogers/runtime that referenced this pull request Dec 10, 2024
…ated in code (dotnet#110078)

* [mono][aot] Fix stack state when emitting type load throw

Method compilation was continuing and we ended up failing with invalid IL.

* [mono][aot] Mark clauses as dead when replacing method code with exception throw

In the final stages of method compilation, when trying to compute clause ranges, we were asserting because the clause bblocks haven't been reached for compilation.
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