-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[mono][aot] Type load checks do not fail at compile time but produce a runtime exception #91261
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I strongly feel we shoudl include the name of the class that failed to load in the exception, whenever possible.
- I'm not sure about clearing the cfg exception field between phases - it feels like we might silently ignore an unhandled problem in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. If possible try to pass the MonoClass* to mono_throw_type_load by encoding the class constant in the AOT image.
…untime errors that were not necessary for the unit tests.
|
The LLVM AOT CI lane failures are related. It seems that there is stack corruption somewhere along the way. |
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| } | ||
| } | ||
|
|
||
| // Maintain linked list consistency. This BB should have been added as the last, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to remove dead blocks between the bb_init and bb_exit which may not have a direct link to them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly not; it seems that unreachable blocks are detected (and removed) without my explicitly doing it. This is the first iteration that seems to work locally, waiting for CI. I may be able to simplify it if CI turns out favorable.
EDIT: Are you aware of any unlinked blocks that should be kept?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good to me. I was just curious whether the unreachable blocks are detected and removed.
Is it possible to skip the bb_init and link the bb_entry with the throw block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had control flow issues when generating LLVM IR without the init block (which was empty no less). I'll see if it can be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative is to restart the compilation, there is already a mechanism to do that if llvm fails, etc. and emit the exception without compiling the rest of the IL.
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Merging, as the changes seem to work OK. Changing the emission to the compilation restart approach is tracked here: #92688 |
When AOTing, type load checks no longer produce a compilation error. When a CIL instruction is known at compile time to fail because of invalid type, it is replaced with throwing a
TypeLoadException. JIT behavior is not affected.A new icall is added to facilitate throwing
TypeLoadException.Additionally, the unit tests
Loader/classloader/explicitlayout/NestedStructs/...are reenabled as they test working with edge case types.The PR also addresses #62311.