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] FullAOT runtime test failures: Attempting to JIT compile method #57350

Closed
imhameed opened this issue Aug 13, 2021 · 3 comments
Closed
Assignees
Labels
area-Codegen-meta-mono runtime-mono specific to the Mono runtime
Milestone

Comments

@imhameed
Copy link
Contributor

imhameed commented Aug 13, 2021

Several runtime tests (which can be found by searching issues.targets for this issue number) fail to pass with this message:

Attempting to JIT compile method '[function name here]' while running in aot-only mode

Tests are run using MONO_ENV_OPTIONS=--full-aot.

FullAOT compilation uses these flags on x64:

MONO_ENV_OPTIONS="--aot=full,llvm,llvm-path=$MONO_PFX,mattr=sse4.2,mattr=popcnt,mattr=lzcnt,mattr=bmi,mattr=bmi2,mattr=pclmul,mattr=aes"

and these on arm64:

MONO_ENV_OPTIONS="--aot=full,llvm,llvm-path=$MONO_PFX,mattr=crc,mattr=crypto"
@imhameed imhameed added area-Codegen-meta-mono runtime-mono specific to the Mono runtime labels Aug 13, 2021
@imhameed imhameed added this to the Future milestone Aug 13, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Aug 13, 2021
@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Aug 13, 2021
@imhameed imhameed changed the title [mono] FullAOT runtime test failure: Attempting to JIT compile method [mono] FullAOT runtime test failures: Attempting to JIT compile method Aug 16, 2021
@lambdageek
Copy link
Member

lambdageek commented Jan 17, 2023

Update I am wrong

Looking at, for example, #80642 which introduced a new testcase that appears to hit this issue, it seems like what is happening is that we need to throw a TypeLoadException during layout of some class, but since we're in the AOT compiler, we're not allowed to run managed code (such as the TLE constructor).

@lambdageek lambdageek modified the milestones: Future, 8.0.0 Jan 17, 2023
@lambdageek
Copy link
Member

lambdageek commented Jan 17, 2023

Update I think i may have misunderstood what is happening (in at least some of the tests).

It looks like the blanket MonoAotIncompatible property in objrefandnonobjrefoverlap/Directory.Build.prop only stops the AOT compiler from running on the assemblies in the directory. IT doesn't prevent the test from running. So on non-full AOT the test runs, falls back to the JIT (or interp) and maybe passes. On fullAOT, the test tries to run, but since the runtime is set to fail if it tries to fall back to the JIT, the execution fails since there's no AOT image available. So the test fails.

Probably the best we can do here is just improve the diagnostic: instead of attempting to throw a TLE and erroring out (because execution is not allowed) we would detect that we're in the AOT compiler and just print a diagnostic message (ideally mentioning the real issue) and exit.

It might see like a better idea is to succeed in compilation and generate code that when called with throw the TLE, but that actually seems pretty hard. For example if the bad class is used as a method parameter we might not be able to generate anything that is callable - so compilation will appear to succeed but it will crash badly (possibly even more confusingly) if the method is called.

I think we should just improve the AOT compiler error message to report the actual cause.

/cc @SamMonoRT - we should talk about this on our next 1-1

@lambdageek
Copy link
Member

We should have a better error message in full AOT mode. Also a better way to skip tests with full AOT than just adding to the issues.targets file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Codegen-meta-mono runtime-mono specific to the Mono runtime
Projects
None yet
Development

No branches or pull requests

5 participants