-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
AOT+LLVM throws for Enum.GetUnderlyingType()
on Android in .NET 7
#68914
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Context: dotnet/runtime#56989 Context: dotnet/runtime#68734 Context: dotnet/runtime#68914 Context: dotnet/runtime#68701 Changes: dotnet/installer@04e40fa...c7afae6 % git diff --shortstat 04e40fa9...c7afae69 98 files changed, 1788 insertions(+), 1191 deletions(-) Changes: dotnet/runtime@a21b9a2...c5d40c9 % git diff --shortstat a21b9a2d...c5d40c9e 28347 files changed, 1609359 insertions(+), 1066473 deletions(-) Changes: dotnet/linker@01c4f59...04c49c9 % git diff --shortstat 01c4f590...04c49c9d 577 files changed, 28039 insertions(+), 10835 deletions(-) Updates to build with the .NET 7 SDK and use the runtime specified by the SDK. We no longer use different SDK & runtime versions. This produces a 7.0.100 Android workload. After this is merged we should be able to enable Maestro to consume future .NET 7 builds from dotnet/installer/main. ~~ Known Issues ~~ AOT+LLVM crashes on startup: * dotnet/runtime#68914 Xamarin.Build.Download hits a breaking change with `ZipEntry`: * dotnet/runtime#68734 * xamarin/XamarinComponents#1368 illink outputs different MVIDs per architecture: * dotnet/linker#2203 * dotnet/runtime#67660 Size of `libmonosgen-2.0.so` regressed: * dotnet/runtime#68330 * dotnet/runtime#68354 Newer .NET 7 builds crash on startup: * dotnet/runtime#68701 * This is worked around by *disabling* lazy loading of AOT'd assemblies 6dc426f. * TODO: re-enable once we get a fixed .NET 7 runtime. TODO: We can't yet push to the `dotnet7` feed. Working on this. Co-authored-by: Jonathan Peppers <[email protected]> Co-authored-by: Peter Collins <[email protected]>
/cc @SamMonoRT |
cc @vargaz - please can you take a look. |
@SamMonoRT this issue is only happening in .NET 7. It looks like the same test is passing in .NET 6. |
Which type is passed to the method ? |
What's "odd" about this stack trace is that it makes no sense. It starts with the
i.e. the We then hit which calls
This brings us to the Which calls Which calls Which is where things make no sense: statically, we know
Thus, throwing the The bug is that (Or AOT+LLVM inlining mumble something?) |
I made some smaller repros here, building xamarin-android/main. I used
(this one might be a different issue, it has a different crash)
I added more logging in xamarin-android to see the exception:
We believe that |
Which aotprofile file is used to AOT these apps ? |
It is this one, which was recorded using .NET 6: Working on another one, but it looks like I have to build a newer |
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger Issue DetailsDescriptionOur
This looks oddly familiar to a related issue in mono/mono: dotnet/android#1842 Looking at the underlying code, I think it throws here: Reproduction StepsBuild a .NET 7 Expected behaviorUse of Actual behaviorUse of Regression?This project appears to be working in .NET 6. Known WorkaroundsDisable LLVM. Configuration.NET 7.0.100-preview.4.22174.1 c7afae6936bf80239aa93bfd3b6f68513d9876d4 Other informationNo response
|
Context: dotnet/runtime#68914 We found that the issue with LLVM only occurs when using Profiled AOT. This is enabled by default for `Release` builds in .NET 6+, so let's try using `-p:AndroidEnableProfiledAot=false`. This at least gets some of our LLVM test coverage running again.
Context: dotnet/runtime#68914 We found that the issue with LLVM only occurs when using Profiled AOT. This is enabled by default for `Release` builds in .NET 6+, so let's try using `-p:AndroidEnableProfiledAot=false`. This at least gets some of our LLVM test coverage running again. When testing this, we started getting a crash: 05-24 15:11:36.809 5024 5024 F DEBUG : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.' It appeared that `Android.App.Application.cctor` was running before `JNIEnv.Initialize()` is complete: 05-25 11:12:33.177 10812 10812 D Mono : AOT: FOUND method Android.Runtime.JNIEnv/<>c:.cctor () [0x78e0d04608 - 0x78e0d04678 0x78e0d6f8a0] 05-25 11:12:33.177 10812 10812 D Mono : Running class .cctor for Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager from 'Mono.Android.dll' 05-25 11:12:33.177 10812 10812 D Mono : AOT: FOUND method Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager:.cctor () [0x78e0d31d24 - 0x78e0d31d64 0x78e0d6f8a0] 05-25 11:12:33.177 10812 10812 D Mono : Running class .cctor for Android.App.Application from 'Mono.Android.dll' By adding an explicit static constructor to `Android.App.Application`, this appears to have workaround this issue.
Context: dotnet/runtime#68914 We found that the issue with LLVM only occurs when using Profiled AOT. This is enabled by default for `Release` builds in .NET 6+, so let's try using `-p:AndroidEnableProfiledAot=false`. This at least gets some of our LLVM test coverage running again. When testing this, we started getting a crash: 05-24 15:11:36.809 5024 5024 F DEBUG : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.' It appeared that `Android.App.Application.cctor` was running before `JNIEnv.Initialize()` is complete: 05-25 11:12:33.177 10812 10812 D Mono : AOT: FOUND method Android.Runtime.JNIEnv/<>c:.cctor () [0x78e0d04608 - 0x78e0d04678 0x78e0d6f8a0] 05-25 11:12:33.177 10812 10812 D Mono : Running class .cctor for Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager from 'Mono.Android.dll' 05-25 11:12:33.177 10812 10812 D Mono : AOT: FOUND method Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager:.cctor () [0x78e0d31d24 - 0x78e0d31d64 0x78e0d6f8a0] 05-25 11:12:33.177 10812 10812 D Mono : Running class .cctor for Android.App.Application from 'Mono.Android.dll' By adding an explicit static constructor to `Android.App.Application`, this appears to have workaround this issue.
Context: dotnet/runtime#68914 We found that the issue with LLVM only occurs when using Profiled AOT. This is enabled by default for `Release` builds in .NET 6+, so let's try using `-p:AndroidEnableProfiledAot=false`. This at least gets some of our LLVM test coverage running again. When testing this, we started getting a crash: 05-24 15:11:36.809 5024 5024 F DEBUG : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.' It appeared that `Android.App.Application.cctor` was running before `JNIEnv.Initialize()` is complete: 05-25 11:12:33.177 10812 10812 D Mono : AOT: FOUND method Android.Runtime.JNIEnv/<>c:.cctor () [0x78e0d04608 - 0x78e0d04678 0x78e0d6f8a0] 05-25 11:12:33.177 10812 10812 D Mono : Running class .cctor for Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager from 'Mono.Android.dll' 05-25 11:12:33.177 10812 10812 D Mono : AOT: FOUND method Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager:.cctor () [0x78e0d31d24 - 0x78e0d31d64 0x78e0d6f8a0] 05-25 11:12:33.177 10812 10812 D Mono : Running class .cctor for Android.App.Application from 'Mono.Android.dll' By adding an explicit static constructor to `Android.App.Application`, this appears to have workaround this issue.
#73304 is also a Enum related failure. I wonder if they could have the same root cause. |
I think #73304 might mean "enumeration", it's this error message after the linker removed the text for it: runtime/src/libraries/System.Collections.NonGeneric/src/Resources/Strings.resx Lines 96 to 98 in a9b3898
I think this is if you use an |
Based on the description here #68914 (comment) I'm trying to make a sample for dotnet/runtime that has the same behavior, and trying to compile it with LLVM. Starting from this: using System;
using System.Runtime.CompilerServices;
public class Base {
public Base () {
Work (((object)this).GetType());
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Work(Type t) {
Console.WriteLine ($"is enum: {t} - {t.IsEnum}");
}
}
public class Child : Base {
public Child() : base () { }
}
public class Program {
public static void Main () {
bool isMono = typeof(object).Assembly.GetType("Mono.RuntimeStructs") != null;
Console.WriteLine($"Hello World {(isMono ? "from Mono!" : "from CoreCLR!")}");
var _ = new Child ();
}
}
Doesn't repro on osx-arm64 desktop with llvmonly or with fullAOT with llvm. going to try android |
Nope, my naive repro doesn't ever return |
@lambdageek this particular issue, I haven't seen last time I tested LLVM. Is it possible some change since May solved this one? I've more recently hit these two:
|
Removing |
Let's just close it, and I can reopen if we hit this again. |
I stumbled across an identical stacktrace while hitting various issues on android + llvmaot. #74796 was fixing it for me. |
Description
Our
Mono.Android-Tests
project crashes on startup with:This looks oddly familiar to a related issue in mono/mono: dotnet/android#1842
Looking at the underlying code, I think it throws here:
https://github.com/xamarin/java.interop/blob/61cdb40dcc8b33d400aef3fd12e0aeee72f71e35/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs#L151-L152
Reproduction Steps
Build a .NET 7
Release
app with-p:EnableLLVM=true
.Expected behavior
Use of
-p:EnableLLVM=true
on Android doesn't crash on startup.Actual behavior
Use of
-p:EnableLLVM=true
crashes on startup on Android.Regression?
This project appears to be working in .NET 6.
Known Workarounds
Disable LLVM.
Configuration
.NET 7.0.100-preview.4.22174.1 c7afae6936bf80239aa93bfd3b6f68513d9876d4
.NET runtime 7.0.0-preview.4.22172.7 c5d40c9
Other information
No response
The text was updated successfully, but these errors were encountered: