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

[android] MAUI app with localized resources build on Windows crashes with non-default culture #9151

Closed
matouskozak opened this issue Jul 25, 2024 · 15 comments
Assignees
Labels
Area: App Runtime Issues in `libmonodroid.so`. need-info Issues that need more information from the author.

Comments

@matouskozak
Copy link
Member

matouskozak commented Jul 25, 2024

Description

Android MAUI app with localized resources crashes in Release configuration on startup with non-default culture. The app crashes when built on Windows, when built on Mac the app works fine. This failure was originally reported in #9153.

When the app is built in Debug configuration, the app doesn't crash. However, the non-default culture is not respected and localized resources for default culture are used.

Reproduction Steps

  1. Install .NET 9 preview 5 and MAUI-android workload
  2. Create a MAUI app using localized resources
  3. Change culture: either in the MauiProgram.cs e.g. with System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("cs-CZ"); or by going into device settings and changing language/location manually.
  4. Build and run the app for android (-f net9.0-android) in Release mode (-c Release)

Expected behavior

The app builds and runs without errors, displaying the localized resources for the changed culture.

Actual behavior

The app crashes on startup with:

07-25 15:06:31.941 14348 14348 D Mono    : Request to load AndroidGlobalizationRepro.resources in alc 0x7c9d68e9ba70
07-25 15:06:31.941 14348 14348 D monodroid-assembly: assembly_store_open_from_bundles: looking for bundled name: 'cs-CZ/AndroidGlobalizationRepro.resources' (hash 0xf878a992386a932a)
07-25 15:06:31.941 14348 14348 D monodroid-assembly: Mapped: image_data == 0x7c9c1850464c; debug_info_data == 0x0; config_data == 0x0; descriptor == 0x7c9c18286348; data size == 3584; debug data size == 0; config data size == 0; name == 'cs-CZ/AndroidGlobalizationRepro.resources'
07-25 15:06:31.942 14348 14348 F monodroid-assembly: Failed to look up image index for hash 0xf878a992386a932a
07-25 15:06:31.942 14348 14348 F monodroid: Abort at /Users/runner/work/1/s/xamarin-android/src/native/monodroid/mono-image-loader.hh:120:5 ('static MonoImage *xamarin::android::internal::MonoImageLoader::stash_and_return(MonoImage *, MonoImageOpenStatus, hash_t)')
--------- beginning of crash
07-25 15:06:31.944 14348 14348 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14348 (balizationrepro), pid 14348 (balizationrepro)
07-25 15:06:32.001 14391 14391 E crash_dump64: failed to get the guest state header for thread 14348: Bad address
07-25 15:06:32.004 14391 14391 E crash_dump64: failed to get the guest state header for thread 14349: Bad address
07-25 15:06:32.004 14391 14391 E crash_dump64: failed to get the guest state header for thread 14350: Bad address
07-25 15:06:32.005 14391 14391 E crash_dump64: failed to get the guest state header for thread 14351: Bad address
07-25 15:06:32.006 14391 14391 E crash_dump64: failed to get the guest state header for thread 14352: Bad address
07-25 15:06:32.007 14391 14391 E crash_dump64: failed to get the guest state header for thread 14353: Bad address
07-25 15:06:32.008 14391 14391 E crash_dump64: failed to get the guest state header for thread 14354: Bad address
07-25 15:06:32.009 14391 14391 E crash_dump64: failed to get the guest state header for thread 14355: Bad address
07-25 15:06:32.011 14391 14391 E crash_dump64: failed to get the guest state header for thread 14357: Bad address
07-25 15:06:32.014 14391 14391 E crash_dump64: failed to get the guest state header for thread 14358: Bad address
07-25 15:06:32.014 14391 14391 E crash_dump64: failed to get the guest state header for thread 14359: Bad address
07-25 15:06:32.016 14391 14391 E crash_dump64: failed to get the guest state header for thread 14360: Bad address
07-25 15:06:32.016 14391 14391 E crash_dump64: failed to get the guest state header for thread 14365: Bad address
07-25 15:06:32.017 14391 14391 E crash_dump64: failed to get the guest state header for thread 14379: Bad address
07-25 15:06:32.018 14391 14391 E crash_dump64: failed to get the guest state header for thread 14380: Bad address
07-25 15:06:32.019 14391 14391 E crash_dump64: failed to get the guest state header for thread 14386: Bad address
07-25 15:06:32.035 14391 14391 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto
07-25 15:06:32.037   220   220 I tombstoned: received crash request for pid 14348
07-25 15:06:32.043 14391 14391 I crash_dump64: performing dump of process 14348 (target tid = 14348)
07-25 15:06:33.330 14391 14391 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-25 15:06:33.330 14391 14391 F DEBUG   : Build fingerprint: 'google/sdk_gphone64_x86_64/emu64xa:15/AP31.240617.003/12088229:user/release-keys'
07-25 15:06:33.330 14391 14391 F DEBUG   : Revision: '0'
07-25 15:06:33.330 14391 14391 F DEBUG   : ABI: 'x86_64'
07-25 15:06:33.331 14391 14391 F DEBUG   : Timestamp: 2024-07-25 15:06:32.055607800+0200
07-25 15:06:33.331 14391 14391 F DEBUG   : Process uptime: 7s
07-25 15:06:33.331 14391 14391 F DEBUG   : Cmdline: com.companyname.androidglobalizationrepro
07-25 15:06:33.331 14391 14391 F DEBUG   : pid: 14348, tid: 14348, name: balizationrepro  >>> com.companyname.androidglobalizationrepro <<<
07-25 15:06:33.331 14391 14391 F DEBUG   : uid: 10212
07-25 15:06:33.331 14391 14391 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
07-25 15:06:33.331 14391 14391 F DEBUG   : Abort message: 'Failed to look up image index for hash 0xf878a992386a932a'
07-25 15:06:33.331 14391 14391 F DEBUG   :     rax 0000000000000000  rbx 00007ffee8f616b8  rcx 00007c9f438e0b90  rdx 0000000000000006
07-25 15:06:33.331 14391 14391 F DEBUG   :     r8  00007c9c9fa5cb31  r9  00007c9c9fa5cb31  r10 00007ffee8f616c0  r11 0000000000000203
07-25 15:06:33.331 14391 14391 F DEBUG   :     r12 00007c9c1850464c  r13 00007ffee8f617e8  r14 000000000000380c  r15 000000000000380c
07-25 15:06:33.331 14391 14391 F DEBUG   :     rdi 000000000000380c  rsi 000000000000380c
07-25 15:06:33.331 14391 14391 F DEBUG   :     rbp 0000000000000e00  rsp 00007ffee8f616b0  rip 00007c9f438e0b90
07-25 15:06:33.331 14391 14391 F DEBUG   : 8 total frames
07-25 15:06:33.331 14391 14391 F DEBUG   : backtrace:
07-25 15:06:33.331 14391 14391 F DEBUG   :       #00 pc 000000000005cb90  /apex/com.android.runtime/lib64/bionic/libc.so (abort+192) (BuildId: eb58b4d427279994f00c0e1818477e4f)
07-25 15:06:33.332 14391 14391 F DEBUG   :       dotnet/runtime#1 pc 00000000000519a4  /data/app/~~9V1o6P8irnAlrqGQAZs_wg==/com.companyname.androidglobalizationrepro-jTqGYFNk8_VOZ6NJ_72RFA==/split_config.x86_64.apk!libmono-android.release.so (offset 0xd16000) (xamarin::android::Helpers::abort_application(bool, std::__ndk1::source_location)+68) (BuildId: bb24bad2340bfc0616b810f2f7ee15d4d085676a)
07-25 15:06:33.332 14391 14391 F DEBUG   :       dotnet/runtime#2 pc 000000000001fc8d  /data/app/~~9V1o6P8irnAlrqGQAZs_wg==/com.companyname.androidglobalizationrepro-jTqGYFNk8_VOZ6NJ_72RFA==/split_config.x86_64.apk!libmono-android.release.so (offset 0xd16000) (xamarin::android::internal::EmbeddedAssemblies::open_from_bundles(void*, _MonoAssemblyName*, char**, void*, _MonoError*)+8973) (BuildId: bb24bad2340bfc0616b810f2f7ee15d4d085676a)
07-25 15:06:33.332 14391 14391 F DEBUG   :       dotnet/runtime#3 pc 000000000024c3a3  /data/app/~~9V1o6P8irnAlrqGQAZs_wg==/com.companyname.androidglobalizationrepro-jTqGYFNk8_VOZ6NJ_72RFA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0xd93000) (BuildId: 0a959315e0893aa7c032cbb6482832586a5811fb)
07-25 15:06:33.333 14391 14391 F DEBUG   :       dotnet/runtime#4 pc 00000000002495b9  /data/app/~~9V1o6P8irnAlrqGQAZs_wg==/com.companyname.androidglobalizationrepro-jTqGYFNk8_VOZ6NJ_72RFA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0xd93000) (mono_assembly_request_byname+1177) (BuildId: 0a959315e0893aa7c032cbb6482832586a5811fb)
07-25 15:06:33.333 14391 14391 F DEBUG   :       dotnet/runtime#5 pc 0000000000246ee6  /data/app/~~9V1o6P8irnAlrqGQAZs_wg==/com.companyname.androidglobalizationrepro-jTqGYFNk8_VOZ6NJ_72RFA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0xd93000) (BuildId: 0a959315e0893aa7c032cbb6482832586a5811fb)
07-25 15:06:33.333 14391 14391 F DEBUG   :       dotnet/runtime#6 pc 0000000000279ce4  /data/app/~~9V1o6P8irnAlrqGQAZs_wg==/com.companyname.androidglobalizationrepro-jTqGYFNk8_VOZ6NJ_72RFA==/split_config.x86_64.apk!libmonosgen-2.0.so (offset 0xd93000) (BuildId: 0a959315e0893aa7c032cbb6482832586a5811fb)
07-25 15:06:33.333 14391 14391 F DEBUG   :       dotnet/runtime#7 pc 0000000000016df3  <anonymous:4157b000>

Regression?

Yes, works with .NET preview 2

Known Workarounds

Use .NET 9 preview 2 or build the app on Mac.

Configuration

  • .NET SDK: 9.0.100-preview.5.24307.3
  • OS: Windows 10.0.22631
  • Architecture: x64

Other information

No response

Copy link

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

@steveisok
Copy link
Member

Looks like it's somehow not respecting the culture you want:

looking for bundled name: 'cs-CZ/AndroidGlobalizationRepro.resources'

@matouskozak
Copy link
Member Author

matouskozak commented Jul 25, 2024

Looks like it's somehow not respecting the culture you want:

looking for bundled name: 'cs-CZ/AndroidGlobalizationRepro.resources'

Sorry, that's a mismatch in the issue description and the reported crash log. The cs-CZ is the desired culture in this case. Updated.

@steveisok
Copy link
Member

Another question, is this a runtime issue or a xamarin-android one? Reason why I ask is they have a custom way of loading assemblies.

@matouskozak
Copy link
Member Author

matouskozak commented Jul 25, 2024

Another question, is this a runtime issue or a xamarin-android one? Reason why I ask is they have a custom way of loading assemblies.

I'm unsure on that. We had a big runtime change related to Globalization shipping after Preview 2 dotnet/runtime#98495.

However, inspecting the binlogs from Preview 2 and Preview 5, I noticed that there are no entries for cs-CZ/AndroidGlobalizationRepro.resources in the Preview 2 log (the functioning app) whereas Preview 5 (broken app) reports multiple entries. This hints that there might have been changes on upper layer related to how localized resources are handled. @jonathanpeppers do you have any ideas on this?

@jonathanpeppers
Copy link
Member

/cc @grendello maybe there is something going wrong with:

@akoeplinger
Copy link
Member

Yeah it does feel more like a dotnet/android issue to me.

@matouskozak
Copy link
Member Author

@jonathanpeppers @grendello would you like me to transfer the issue to dotnet/android?

@grendello
Copy link
Contributor

@matouskozak yes, please. It does look like an issue with our app build process.

@akoeplinger akoeplinger transferred this issue from dotnet/runtime Jul 29, 2024
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Jul 29, 2024
@grendello grendello self-assigned this Jul 29, 2024
@jonpryor
Copy link
Member

@matouskozak: was this app built on Windows? If so, it may be fixed by #9315.

@matouskozak
Copy link
Member Author

@matouskozak: was this app built on Windows? If so, it may be fixed by #9315.

Yes, it was windows-only issue for me and looked related to the other Android crashes related to library loading. Is the fix part of any RC release already so that I can try it out?

@grendello
Copy link
Contributor

It's going to be part of RC2, it's in the branch here. You could test the fix before the release by getting nuget packages from the nuget-signed folder and manually replacing files. Nuget containing the fix is named Microsoft.Android.Sdk.Windows.35.0.0-rc.2.145.nupkg

@jpobst
Copy link
Contributor

jpobst commented Oct 30, 2024

Sounds like this should be fixed in .NET 9 RC2. Did you get a chance to test on the latest preview?

@jpobst jpobst added need-info Issues that need more information from the author. Area: App Runtime Issues in `libmonodroid.so`. and removed needs-triage Issues that need to be assigned. labels Oct 30, 2024
Copy link

Hi @matouskozak. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@matouskozak
Copy link
Member Author

Sounds like this should be fixed in .NET 9 RC2. Did you get a chance to test on the latest preview?

Sorry, I had problems with my Windows dev machine. I just tried it out and I'm getting no more errors. Thank you for fixing.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App Runtime Issues in `libmonodroid.so`. need-info Issues that need more information from the author.
Projects
None yet
Development

No branches or pull requests

7 participants