-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[monodroid] Properly process satellite assemblies (#7823)
Fixes: #7819 Our native runtime uses a cache of pointers to loaded managed assembly images (essentially an array of the native `struct MonoImage` pointers) which is pre-allocated at build time and placed in the native `libxamarin-app.so` library. While generating the cache, we also generate hashes for a number of assembly name permutations (currently two per assembly: with and without the extension). Only unique assembly names are considered when generating the cache (it's possible to have duplicate names, because we package more than one copy of some assemblies - those which are architecture specific). This algorithm had a bug which made it ignore culture prefix in satellite assembly names (e.g. `en/MyAssembly.resources.dll`); instead of several entries for each culture, we generated only two entries (e.g. `MyAssembly.resources.dll` and `MyAssembly.resources`) but we still counted each culture-prefixed assembly and stored that number in `libxamarin-app.so` to be used at runtime to calculate number of entries in the cache. This made the array storing cached `MonoImage*` pointers to be smaller than the number of actual assemblies in the APK times 2 and in some cases we failed to look up pointer to some images and, as the result, passed a `NULL` pointer to MonoVM which then caused a segmentation fault trying to dereference the pointer: F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x000000000000001c F DEBUG : Cause: null pointer dereference … F DEBUG : #00 pc 00000000000bdad8 /data/app/~~7gCkYmQcKwTyS9NmxfgKxA==/com.companyname.bubby-PJIkJ0Lv0RiQhEVLeWi4wg==/split_config.arm64_v8a.apk!libmonosgen-2.0.so (mono_class_get_checked+24) (BuildId: 80b786675a56824331f363bf29a2b54f454cf006) Update the `<BuildApk/>` task to stop ignoring the culture prefix for satellite assemblies in order to avoid the situation. Additionally, since the previous assumption that MonoVM will validate all pointers passed to its APIs turned out to be unwarranted, we now check more carefully for `NULL` pointers when trying to obtain a native function pointer from the MonoVM runtime. Add a test for the issue, based on the `MissingSatelliteAssemblyInLibrary()` packaging test which, when it fails, will result in a `SIGABRT`: D monodroid-assembly: assembly_store_open_from_bundles: looking for bundled name: 'System.Private.CoreLib' (hash 0x6b0ff375198b9c17) F monodroid-assembly: Invalid assembly index 19, exceeds the maximum index of 11 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 17957 (semblyinlibrary), pid 17957 (semblyinlibrary) Enhance the packaging test `MissingSatelliteAssemblyInLibrary()` by adding more languages, to see if they're all packaged correctly.
- Loading branch information
Showing
5 changed files
with
69 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters