android: [android] MAUI app with localized resources build on Windows crashes with non-default culture
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 https://github.com/dotnet/android/issues/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
- Install .NET 9 preview 5 and MAUI-android workload
- Create a MAUI app using localized resources
- Change culture: either in the
MauiProgram.cse.g. withSystem.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("cs-CZ");or by going into device settings and changing language/location manually. - 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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 15 (13 by maintainers)
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-signedfolder and manually replacing files. Nuget containing the fix is namedMicrosoft.Android.Sdk.Windows.35.0.0-rc.2.145.nupkg@matouskozak: was this app built on Windows? If so, it may be fixed by #9315.