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

Crash on startup on Android in Release when referencing a class with non ascii characters from a class library #82187

Closed
CodeAuChocolat opened this issue Feb 15, 2023 · 12 comments · Fixed by #83273

Comments

@CodeAuChocolat
Copy link

Description

I have a class Tür in a .NET 7 class library and I reference this class in a MAUI-App. When compiled in Release with AOT enabled, on an Android device, the app crashes immediatly.
Works on Windows.
Works on Android Emulator

I am using Visual Studio 17.4.5.

Installed Workload Id Manifest Version Installation Source

maui 7.0.59/7.0.100 SDK 7.0.200

Steps to Reproduce

  1. Create a new .NET MAUI App
  2. Create a .NET 7 class library
  3. Add a Reference to the class libarary to the MAUI app
  4. Add a class Tür to the class library
  5. Add a field to App.xaml.cs using the class Tür
  6. Run the app on an android device in Release

Link to public reproduction project repository

https://github.com/CodeAuChocolat/MauiUmlautCrash

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 7, Android 12

Did you find any workaround?

Rename class or disable AOT

Relevant log output

Time	Device Name	Type	PID	Tag	Message
02-15 10:04:07.288	CipherLab RS31	Error	18286	AndroidRuntime	android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not load type of field 'MauiUmlautCrash.App:_tor' (0) due to: Could not resolve type with token 01000058 from typeref (expected class 'UmlautLib.Tür' in assembly 'UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:UmlautLib.Tür member:(null)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags , Binder , Object[] , CultureInfo )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type )
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type , Func`2 )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type )
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type )
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IApplication](IServiceProvider )
   at Microsoft.Maui.MauiApplication.OnCreate()
   at Android.App.Application.n_OnCreate(IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
	at crc6488302ad6e9e4df1a.MauiApplication.n_onCreate(Native Method)
	at crc6488302ad6e9e4df1a.MauiApplication.onCreate(MauiApplication.java:28)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5503)
	at android.app.ActivityThread.-wrap2(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
	at android.os.Handler.dispatchMessage(Handler.java:110)
	at android.os.Looper.loop(Looper.java:203)
	at android.app.ActivityThread.main(ActivityThread.java:6251)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = send_action_app_error , value = 1
 from settings cache , name = logcat_for_data_app_crash , value = null
  Force finishing activity com.companyname.mauiumlautcrash/crc642a249426a1f98bd8.MainActivity
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = dropbox_age_seconds , value = null
 from settings cache , name = dropbox_max_files , value = null
 from settings cache , name = dropbox_quota_percent , value = null
 from settings cache , name = dropbox_reserve_percent , value = null
 from settings cache , name = dropbox_quota_kb , value = null
@rachelkang rachelkang transferred this issue from dotnet/maui Feb 15, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 15, 2023
@ghost
Copy link

ghost commented Feb 15, 2023

Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I have a class Tür in a .NET 7 class library and I reference this class in a MAUI-App. When compiled in Release with AOT enabled, on an Android device, the app crashes immediatly.
Works on Windows.
Works on Android Emulator

I am using Visual Studio 17.4.5.

Installed Workload Id Manifest Version Installation Source

maui 7.0.59/7.0.100 SDK 7.0.200

Steps to Reproduce

  1. Create a new .NET MAUI App
  2. Create a .NET 7 class library
  3. Add a Reference to the class libarary to the MAUI app
  4. Add a class Tür to the class library
  5. Add a field to App.xaml.cs using the class Tür
  6. Run the app on an android device in Release

Link to public reproduction project repository

https://github.com/CodeAuChocolat/MauiUmlautCrash

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 7, Android 12

Did you find any workaround?

Rename class or disable AOT

Relevant log output

Time	Device Name	Type	PID	Tag	Message
02-15 10:04:07.288	CipherLab RS31	Error	18286	AndroidRuntime	android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not load type of field 'MauiUmlautCrash.App:_tor' (0) due to: Could not resolve type with token 01000058 from typeref (expected class 'UmlautLib.Tür' in assembly 'UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:UmlautLib.Tür member:(null)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags , Binder , Object[] , CultureInfo )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type )
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type , Func`2 )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type )
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type )
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IApplication](IServiceProvider )
   at Microsoft.Maui.MauiApplication.OnCreate()
   at Android.App.Application.n_OnCreate(IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
	at crc6488302ad6e9e4df1a.MauiApplication.n_onCreate(Native Method)
	at crc6488302ad6e9e4df1a.MauiApplication.onCreate(MauiApplication.java:28)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5503)
	at android.app.ActivityThread.-wrap2(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
	at android.os.Handler.dispatchMessage(Handler.java:110)
	at android.os.Looper.loop(Looper.java:203)
	at android.app.ActivityThread.main(ActivityThread.java:6251)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = send_action_app_error , value = 1
 from settings cache , name = logcat_for_data_app_crash , value = null
  Force finishing activity com.companyname.mauiumlautcrash/crc642a249426a1f98bd8.MainActivity
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = dropbox_age_seconds , value = null
 from settings cache , name = dropbox_max_files , value = null
 from settings cache , name = dropbox_quota_percent , value = null
 from settings cache , name = dropbox_reserve_percent , value = null
 from settings cache , name = dropbox_quota_kb , value = null
Author: CodeAuChocolat
Assignees: -
Labels:

area-Extensions-DependencyInjection

Milestone: -

@steveharter
Copy link
Member

Based on above this looks like an AOT issue with non-ascii characters used in a type name.

@ghost
Copy link

ghost commented Feb 22, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I have a class Tür in a .NET 7 class library and I reference this class in a MAUI-App. When compiled in Release with AOT enabled, on an Android device, the app crashes immediatly.
Works on Windows.
Works on Android Emulator

I am using Visual Studio 17.4.5.

Installed Workload Id Manifest Version Installation Source

maui 7.0.59/7.0.100 SDK 7.0.200

Steps to Reproduce

  1. Create a new .NET MAUI App
  2. Create a .NET 7 class library
  3. Add a Reference to the class libarary to the MAUI app
  4. Add a class Tür to the class library
  5. Add a field to App.xaml.cs using the class Tür
  6. Run the app on an android device in Release

Link to public reproduction project repository

https://github.com/CodeAuChocolat/MauiUmlautCrash

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 7, Android 12

Did you find any workaround?

Rename class or disable AOT

Relevant log output

Time	Device Name	Type	PID	Tag	Message
02-15 10:04:07.288	CipherLab RS31	Error	18286	AndroidRuntime	android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not load type of field 'MauiUmlautCrash.App:_tor' (0) due to: Could not resolve type with token 01000058 from typeref (expected class 'UmlautLib.Tür' in assembly 'UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:UmlautLib.Tür member:(null)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags , Binder , Object[] , CultureInfo )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type )
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type , Func`2 )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type )
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type )
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IApplication](IServiceProvider )
   at Microsoft.Maui.MauiApplication.OnCreate()
   at Android.App.Application.n_OnCreate(IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
	at crc6488302ad6e9e4df1a.MauiApplication.n_onCreate(Native Method)
	at crc6488302ad6e9e4df1a.MauiApplication.onCreate(MauiApplication.java:28)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5503)
	at android.app.ActivityThread.-wrap2(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
	at android.os.Handler.dispatchMessage(Handler.java:110)
	at android.os.Looper.loop(Looper.java:203)
	at android.app.ActivityThread.main(ActivityThread.java:6251)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = send_action_app_error , value = 1
 from settings cache , name = logcat_for_data_app_crash , value = null
  Force finishing activity com.companyname.mauiumlautcrash/crc642a249426a1f98bd8.MainActivity
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = dropbox_age_seconds , value = null
 from settings cache , name = dropbox_max_files , value = null
 from settings cache , name = dropbox_quota_percent , value = null
 from settings cache , name = dropbox_reserve_percent , value = null
 from settings cache , name = dropbox_quota_kb , value = null
Author: CodeAuChocolat
Assignees: -
Labels:

untriaged, area-NativeAOT-coreclr

Milestone: -

@ghost
Copy link

ghost commented Feb 23, 2023

Tagging subscribers to 'arch-android': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I have a class Tür in a .NET 7 class library and I reference this class in a MAUI-App. When compiled in Release with AOT enabled, on an Android device, the app crashes immediatly.
Works on Windows.
Works on Android Emulator

I am using Visual Studio 17.4.5.

Installed Workload Id Manifest Version Installation Source

maui 7.0.59/7.0.100 SDK 7.0.200

Steps to Reproduce

  1. Create a new .NET MAUI App
  2. Create a .NET 7 class library
  3. Add a Reference to the class libarary to the MAUI app
  4. Add a class Tür to the class library
  5. Add a field to App.xaml.cs using the class Tür
  6. Run the app on an android device in Release

Link to public reproduction project repository

https://github.com/CodeAuChocolat/MauiUmlautCrash

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 7, Android 12

Did you find any workaround?

Rename class or disable AOT

Relevant log output

Time	Device Name	Type	PID	Tag	Message
02-15 10:04:07.288	CipherLab RS31	Error	18286	AndroidRuntime	android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not load type of field 'MauiUmlautCrash.App:_tor' (0) due to: Could not resolve type with token 01000058 from typeref (expected class 'UmlautLib.Tür' in assembly 'UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:UmlautLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:UmlautLib.Tür member:(null)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags , Binder , Object[] , CultureInfo )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite , RuntimeResolverContext )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type )
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type , Func`2 )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type )
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type )
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IApplication](IServiceProvider )
   at Microsoft.Maui.MauiApplication.OnCreate()
   at Android.App.Application.n_OnCreate(IntPtr , IntPtr )
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )
	at crc6488302ad6e9e4df1a.MauiApplication.n_onCreate(Native Method)
	at crc6488302ad6e9e4df1a.MauiApplication.onCreate(MauiApplication.java:28)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5503)
	at android.app.ActivityThread.-wrap2(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
	at android.os.Handler.dispatchMessage(Handler.java:110)
	at android.os.Looper.loop(Looper.java:203)
	at android.app.ActivityThread.main(ActivityThread.java:6251)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = send_action_app_error , value = 1
 from settings cache , name = logcat_for_data_app_crash , value = null
  Force finishing activity com.companyname.mauiumlautcrash/crc642a249426a1f98bd8.MainActivity
 from settings cache , name = dropbox:data_app_crash , value = null
 from settings cache , name = dropbox_age_seconds , value = null
 from settings cache , name = dropbox_max_files , value = null
 from settings cache , name = dropbox_quota_percent , value = null
 from settings cache , name = dropbox_reserve_percent , value = null
 from settings cache , name = dropbox_quota_kb , value = null
Author: CodeAuChocolat
Assignees: -
Labels:

os-android, untriaged, area-Codegen-AOT-mono

Milestone: -

@steveisok steveisok removed the untriaged New issue has not been triaged by the area owner label Mar 7, 2023
@steveisok steveisok added this to the Future milestone Mar 7, 2023
@steveisok
Copy link
Member

/cc @SamMonoRT

@lambdageek
Copy link
Member

Is the trimmer running when we build for Android in Release mode for devices? Maybe it removed Tür but not the field reference?

@lambdageek
Copy link
Member

lambdageek commented Mar 7, 2023

I can repro with a Release build running on an arm64 emulator on an arm64 mac.

A colleague couldn't repro with an x64 android emulator. somehow it's arch-specific??

@lambdageek lambdageek self-assigned this Mar 7, 2023
@lambdageek
Copy link
Member

I don't think it's a trimmer issue. afaict the trimmer didn't change the assembly.

Usually these class setup errors come from the class loader, but I really don't get why the class loader would care about the architecture.

We do cache some class info in the AOT data, which could affect startup on AOT. But I didn't think the backend for that was arch-specific...

@marek-safar marek-safar modified the milestones: Future, 8.0.0 Mar 8, 2023
@lambdageek
Copy link
Member

Possible dupe of #78638

@lambdageek
Copy link
Member

One place where the AOT compiler and class names interact is in mono_aot_get_class_from_name which is installed with mono_install_get_class_from_name and then used in mono_class_from_name_checked_aux. When an AOT image is present, it stores a hash table mapping every namespace.name to its type def table token. It's possible that the input to the hash function is different when the table is constructed (in emit_class_name_table) vs when it's used at runtime.

But:

  1. I don't see any such difference that would manifest for names with utf-8 multi-byte characters. (Although a class named , or + or something will expose a bug: aot-compiler calls mono_type_get_name_full which calls mono_identifier_escape_type_name_chars, but aot-runtime doesn't do the same escaping)
  2. Why would it only show up on arm64 android and not on x64 or in any ios testing??

@lambdageek
Copy link
Member

It's definitely the AOT name cache. if I hack mono_class_from_name_checked_aux to print a message whenever it can't find a name in the AOT cache, I can see that it can't find the Tür class. Moreover if I change the code to fallback to doing a metadata lookup instead of failing immediately, the crash goes away and the app runs.

I don't really want to check-in the fallback, though - this should be a cache hit.

Next step is to instrument the AOT compiler and AOT runtime and compare the hash codes going into the table and the hash codes that are looked up.

@lambdageek
Copy link
Member

lambdageek commented Mar 10, 2023

Oh god... it is some signed vs unsigned char nonsense.
This is what the AOT compiler sees:

'MauiUmlautCrash.MeineTüre'=00000038

This is what the android device is trying to look up

03-10 12:33:13.637  6694  6694 W mauiumlautcrash: aleksey - AOT cache 'MauiUmlautCrash.MeineTüre'=0000002b not found

This is the hash implementation

guint
mono_metadata_str_hash (gconstpointer v1)
{
	/* Same as g_str_hash () in glib */
	char *p = (char *) v1;
	guint hash = *p;

	while (*p++) {
		if (*p)
			hash = (hash << 5) - hash + *p;
	}

	return hash;
}

UTF-8 continuation bytes have the top bit set, so if char is signed on one device and unsigned on another, the hash computation will be different - godbolt link

lambdageek added a commit to lambdageek/runtime that referenced this issue Mar 10, 2023
The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes dotnet#82187
Fixes dotnet#78638
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 10, 2023
github-actions bot pushed a commit that referenced this issue Mar 11, 2023
The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes #82187
Fixes #78638
lambdageek added a commit to lambdageek/mono that referenced this issue Mar 11, 2023
The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes dotnet/runtime#82187
Fixes dotnet/runtime#78638
github-actions bot pushed a commit to mono/mono that referenced this issue Mar 11, 2023
The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes dotnet/runtime#82187
Fixes dotnet/runtime#78638
akoeplinger pushed a commit to mono/mono that referenced this issue Mar 13, 2023
Backport of dotnet/runtime#83273 to mono/mono `main`

The C standard does not specify whether `char` is signed or unsigned, it is implementation defined.

Apparently Android aarch64 makes a different choice than other platforms (at least macOS arm64 and Windows x64 give different results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime to optimize class name lookup.  As a result, classes whose names include UTF-8 continuation bytes (with the high bit = 1) will hash differently in the AOT compiler and on the device.

Contributes to dotnet/runtime#82187 
Contributes to dotnet/runtime#78638
akoeplinger pushed a commit to mono/mono that referenced this issue Mar 13, 2023
Backport of dotnet/runtime#83273 to mono/mono `2020-02`

The C standard does not specify whether `char` is signed or unsigned, it is implementation defined.

Apparently Android aarch64 makes a different choice than other platforms (at least macOS arm64 and Windows x64 give different results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime to optimize class name lookup.  As a result, classes whose names include UTF-8 continuation bytes (with the high bit = 1) will hash differently in the AOT compiler and on the device.

Contributes to dotnet/runtime#82187 
Contributes to dotnet/runtime#78638
lambdageek added a commit that referenced this issue Mar 13, 2023
* [mono] Use `unsigned char` when computing UTF8 string hashes

The C standard does not specify whether `char` is signed or unsigned, it is implementation defined.

Apparently Android aarch64 makes a different choice than other platforms (at least macOS arm64 and Windows x64 give different results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime to optimize class name lookup.  As a result, classes whose names include UTF-8 continuation bytes (with the high bit = 1) will hash differently in the AOT compiler and on the device.

Fixes #82187
Fixes #78638

* [aot] add DEBUG_AOT_NAME_TABLE code for debugging the class names

   AOT compiler: Emits a second "class_name_table_debug" symbol that has all the class names and hashes as strings.

   AOT runtime: warns if a class is not found in the name cache

* Add regression test
lambdageek added a commit that referenced this issue Mar 14, 2023
The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes #82187
Fixes #78638
lambdageek added a commit to lambdageek/runtime that referenced this issue Mar 14, 2023
The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes dotnet#82187
Fixes dotnet#78638
@marek-safar marek-safar modified the milestones: 8.0.0, 6.0.x Mar 21, 2023
lambdageek added a commit that referenced this issue Mar 30, 2023
…hes (#83303)

* [mono] Use `unsigned char` when computing UTF8 string hashes

The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes #82187
Fixes #78638

* Add regression test

---------

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
lambdageek added a commit that referenced this issue Mar 30, 2023
…es (#83302)

* [mono] Use `unsigned char` when computing UTF8 string hashes

The C standard does not specify whether `char` is signed or unsigned,
it is implementation defined.

Apparently Android aarch64 makes a different choice than other
platforms (at least macOS arm64 and Windows x64 give different
results).

Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime
to optimize class name lookup.  As a result, classes whose names
include UTF-8 continuation bytes (with the high bit = 1) will hash
differently in the AOT compiler and on the device.

Fixes #82187
Fixes #78638

* Add regression test
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 30, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants